标签:names name har tchar str turn main 出错 int
using namespace std;
class aa{
int num;
public:
aa(){
int b =10;
num = b;
};
void out1(){
cout<<num<<endl;
}
void out2() const{
cout<<num<<endl;
}
void out3() const{
num+=10; //出错,const函数不能修改其数据成员
cout<<num<<endl;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
aa a1;
a1.out1();
a1.out2();
a1.out3();
const aa a2;
a2.out1(); // 错误,const的成员 不能访问非const的函数
a2.out2();
a2.out3();
return 0;
}
标签:names name har tchar str turn main 出错 int
原文地址:https://www.cnblogs.com/DXGG-Bond/p/13071294.html