摘要:
一。凡是不用修改类的成员的函数尽量定义为const函数!比如在取成员变量的值的时候,这样也可以尽量避免bug,而且是在编译的时候就不能通过!另外就是const函数是不能调用非const函数的,即是是哪个非const函数体内没有修改成员变量的值也不行!例如下面的代码编译会不通过:View Code #include<iostream>using namespace std;class studentInfo{public: void setScore(int score){this->score=score;} int getScore() const{printScore() 阅读全文
posted @ 2011-10-06 23:16
下一个路口
阅读(290)
评论(0)
推荐(0)
浙公网安备 33010602011771号