http://blog.csdn.net/anye3000/article/details/6578262
#include <iostream> using namespace std; void main() { int a = 10; int **pTest = new int*; int *pSec = &a; pTest = &pSec; *pTest = pSec; cout<<*pTest<<endl; cout<<pSec<<endl; cout<<**pTest<<endl; //修改一个指针的值 *pSec = 100; cout<<**pTest<<endl; //测试引用 int &b = a; cout<<b<<endl; b = 1000; cout<<a<<' '<<b<<endl; //int *&pRef = &a;//error. int*pRef = &a; int* &pNef = pRef; //修改变量a的值 *pRef = 2000;//通过指针修改a的值 cout<<a<<endl; //a的值被修改 *pNef = 3000; cout<<a<<endl;//通过指针的引用修改变量a的值 cout<<pRef<<endl; }
数组的引用和指针的引用非常类似,因为数组名本身也是一个地址;对二维数组而言,我们传参的方式有三种