#include<iostream>
using namespace std;
int a = 3;
int M = 5;
/*使用一级指针 不能修改 指针的指向
void changePointer(int* p)
{
p = &M ;
}*/
void changePointer(int** p)
{
cout<<"p的地址是:"<<&p<<endl;
cout<<"p指向的地址是:"<<&(*p)<<endl;
*p = &M; //运行完毕 p的地址不变
cout<<"修改后p指向的地址是:"<<&(*p)<<endl;
}
void main()
{
int *b = &a;
int **c = &b;
cout<<"a的地址为:"<<&a<<endl;
cout<<"M的地址为:"<<&M<<endl;
cout<<"b指向的地址为:"<<&(*b)<<endl;
cout<<"b的地址为:"<<&b<<endl;
cout<<"c指向的地址为:"<<&(*c)<<endl;
cout<<"c的地址为:"<<&c<<endl;
cout<<"c指向的地址b指向的地址为:"<<&(**c)<<endl;
//怎么通过c 来修改 a的值呢?
changePointer(&b);
//只是改变了函数体内部p的指向地址
cout<<"修改后b指向的地址为:"<<&(*b)<<endl;
}#include<iostream>
using namespace s