摘要:
一些成员函数改变对象,一些成员函数不改变对象。例如:int Point::GetY(){ return yVal;} 这个函数被调用时,不改变Point对象,而下面的函数改变Point对象:void Point:: SetPt (int x, int y){ xVal=x; yVal=y;} 为了使成员函数的意义更加清楚,我们可在不改变对象的成员函数的函数原型中加上const说明: class Point { public: int GetX() const; int GetY() const; void SetPt (int, int); void OffsetPt (int, i... 阅读全文
摘要:
char greeting[] = "hello";char* p = greeting; //non-const pointer,non-const dataconst char* p = greeting; //non-const pointer, const datachar* const p = greeting; //const pointer,non-const dataconst char* const p = greeting; //const pointer, const ... 阅读全文