#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.shnenglu.com/tgh621/archive/2008/04/15/47100.aspx?opt=admin
posted on 2010-08-09 17:16
胡滿超 閱讀(199)
評論(0) 編輯 收藏 引用