已知:print( )函数是一个类的常成员函数,它无返回值,下列表示中,( )是正确的
记住就好:
int print(int i ) const; // function print is const
int print(const int i); //argument is const
int n;
const int * pc = &n; // pc is a non-const pointer to a const int
// *pc = 2; // Error: n cannot be changed through p without a cast
pc = NULL; // OK: pc itself can be changed
int * const cp = &n; // cp is a const pointer to a non-const int
*cp = 2; // OK to change n through cp
// cp = NULL; // Error: cp itself cannot be changed
int * const * pcp = &cp; // non-const pointer to const pointer to non-const int