// 常量指针
int const * p;
const int * p;
// 指针常量
int * const p;
#include <iostream>
using namespace std;
int main()
{
char str1[] = "123"; //程序运行前就分配的内存空间
char str2[] = "123";
cout << (str1 == str2) << endl; // 0, 两个字符数组分配的地址空间肯定不一样
char *str3 = "123";
char *str4 = "123";
const char *str5 = "123";
cout << "str5= " << str5 << endl;
char const *str6 = "123";
char * const str7 = "123";
cout << (str3 == str4) << endl; // 1
cout << (str3 == str5) << endl; // 1
cout << (str3 == str6) << endl; // 1
cout << (str3 == str7) << endl; // 1
int a = 200;
const int * ppt = &a;
cout << "ppt= " << *ppt << endl;
int b = 100;
ppt = &b; //指针ppt本身的值可以改变
cout << "ppt= " << *ppt << endl;
//*ppt = b;
int * const cht = &a;
cout << "cht= " << *cht << endl;
*cht = b; // cht指向的对象值可以改变
cout << "cht= " << *cht << endl;
int const* const thr = &a;
cout << "thr= " << *thr << endl;
a = 900; // 通过改变a的值来改变thr指向对象的值
cout << "thr= " << *thr << endl;
return 0;
}