int _tmain(int argc, _TCHAR* argv[])
{
int b =100;
constint* a =&b;
//*a = 1201; //wrong error C3892: 'a' : you cannot assign to a variable that is constint c =200;
int*const aa =&b;
*aa =1000; //okey
//aa = &c; wrong 指针值不可以变return0;
}
const表示只读,你不能修改它,但是可以初始化! 应用于:定义常量,const int N = 5;相当于C语言#define N 5 传递参数的修饰符,void f(const char* p)这样就不能修改p指向的内容,只能读其内容,类似的有const引用, 作为类成员函数修饰符,如: class A{ void f()const{...} }; 这样函数f()不能修改类成员,只能读取内成员