#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
胡满超 阅读(195)
评论(0) 编辑 收藏 引用