const (need to be cleaned up)

1.const as "const variable"
2.function parameters
together with "&"
int add(int &a);//can be modified
int add(const int &a);//can't be modified 
//but more efficient than int add(int a); no value copy
3.override function
int add();
int add() const;
//different function;
4.return value
class A;
const A add();
the return value of add(), can't use as left value.
5.const member of class
must be initialized in the constructor function list.
only const function can visit const member.?
6.const member function
class{
int a;
void adda()const{a++;}//cant modify
}
const function cant modify member of the class.
7.const object
nothing in the object can be modified.
it can only call const function

posted @ 2012-04-06 21:44  cascais  阅读(177)  评论(0编辑  收藏  举报