C++中private的作用域,const对象调用非const函数的问题
摘要:最近学习C++,用复制构造函数,产生了一些疑问。 1 class test{ 2 private: 3 int a; 4 public: 5 test(); 6 test(const test& T){ 7 a = T.a; 8 }; 9 ~test();10 int getdate();//返回a的值,实现我就不写了11 }这样写是可以直接把T的成员变量a的值赋给本类的a的。这说明private的作用域是相对于类而言的,而不是相对于某一个对象的类而言,只要是在同样名字的一个类中都是可以直接调用privat...
阅读全文
posted @
2012-11-11 14:49
曾经的你|
阅读(1092)
推荐(0) 编辑