类成员变量私有化
摘要:
类成员变量私有化,通过读写函数进行访问,这样一方面提供了一致的方式(函数)进行类成员变量访问,另一方面为以后的变化提供便宜。看下面的代码: 1class a 2{ 3public: 4 a(int x):x(x) 5 { 6 7 } 8 ~a() 9 {1011 }12public:13 int x;14};1516void f1(const... 阅读全文
posted @ 2006-11-26 23:02 小峰 阅读(402) 评论(0) 推荐(0)