随笔 - 89  文章 - 118  trackbacks - 0
<2010年8月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234

留言簿(16)

随笔分类(56)

随笔档案(89)

文章分类

推荐博客

搜索

  •  

最新随笔

最新评论

阅读排行榜

#include <stdlib.h> #include <iostream>
using namespace std;

class tgh
{
public:
    tgh():i(
3){}
   
const int a() const {return 5;}
   
int a(){return i;}
protected:
   
int i;
private:
};

void main()
{
   
const tgh v;
    tgh s;
   
const int i=s.a();//调用的是int a()
   
int const j=s.a();//调用的是int a()
    printf(
"%d,%d",j,i);
   
const int k = v.a();//调用的是const int a() 
    cout
<<k<<endl;
    system(
"pause");
}

结果是3,35

转自:http://www.cppblog.com/tgh621/archive/2008/04/15/47100.aspx?opt=admin
posted on 2010-08-09 17:16 胡满超 阅读(185) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理