文章目录
const 修饰
const int * t 和 int const * t是等价的
因此可以看出const 是对前生效。
#include <iostream>
using namespace std;
int main()
{
int mt = 122;
int nt = 124;
int tt = 123;
const int * tmnp = &tt;
int const * mcnt = &mt;
int * const ncmt = &nt;
*tmnp = 123;
//*mcnt = 123;
mcnt = &nt;
tmnp = &nt;
//ncmt = &mt;
cout <<*mcnt<<endl;
cout <<*ncmt<<endl;
return 0;
}