//指向变量的指针变量及指向常量的指针变量...
//2007.06.26.WaNGs.TeAMs...
#include <iostream>
#include <string>
using namespace std;
main ()
{
int x,y;
const int z=99;
int *pointer1,*pointer2;
const int *pointer3;
x=10,y=20;
pointer1=&x,pointer2=&y;
pointer3=&z;
cout<<"x="<<x<<", "<<"y="<<y<<", "<<"z="<<z<<", "<<endl;
cout<<"*pointer1="<<*pointer1<<", "<<"*pointer2="<<*pointer2<<", "<<"*pointer3="<<*pointer3<<", "<<endl;
cout<<endl<<"p1 and p3 's address has changed."<<endl;
pointer1=&y; //·2 error C2440: '=' : cannot convert from 'const int *' to 'int *'
pointer3=&x; //·1
cout<<"*pointer1="<<*pointer1<<", "<<"*pointer2="<<*pointer2<<", "<<"*pointer3="<<*pointer3<<", "<<endl;
cout<<endl<<"p1 and p3 will renew."<<endl;
*pointer1=99; //·3
// *pointer3=99; //·4 the const pointer do not renew a value to a const number.
cout<<"*pointer1="<<*pointer1<<", "<<"*pointer2="<<*pointer2<<", "<<"*pointer3="<<*pointer3<<", "<<endl;
/* 问题1:你可以把一个INT类型值赋给CONST INT *POINTER3,如://·1
但是你无法将一个CONST INT类型值赋给INT *POINTER1,如://·2
问题2:你可以通过一个INT *POINTER给其指向的变量重新赋值,如://·3
但是你无法通过一个CONST INT *POINTER给其指向的变量重新赋值,如//·4
*/
return 0;
}