c++中reference是什么意思int **p1; // p1 is a pointer to a pointer to an int.int *&p2; // p2 is a reference to a pointer to an int.int *p3; // ERROR:Pointer to a reference is illegal.int &p4; // ERROR:Reference to a reference is illegal.

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/25 13:40:03
c++中reference是什么意思int**p1;//p1isapointertoapointertoanint.int*&p2;//p2isareferencetoapointertoanint.

c++中reference是什么意思int **p1; // p1 is a pointer to a pointer to an int.int *&p2; // p2 is a reference to a pointer to an int.int *p3; // ERROR:Pointer to a reference is illegal.int &p4; // ERROR:Reference to a reference is illegal.
c++中reference是什么意思
int **p1; // p1 is a pointer to a pointer to an int.
int *&p2; // p2 is a reference to a pointer to an int.
int *p3; // ERROR:Pointer to a reference is illegal.
int &p4; // ERROR:Reference to a reference is illegal.

c++中reference是什么意思int **p1; // p1 is a pointer to a pointer to an int.int *&p2; // p2 is a reference to a pointer to an int.int *p3; // ERROR:Pointer to a reference is illegal.int &p4; // ERROR:Reference to a reference is illegal.
简单的说就是一个“别名”而已~比如罗纳尔多,又叫做胖罗,肥罗,外星人,都是指一个人,罗纳尔多进球了就等于是胖罗,肥罗,外星人进球了~行为跟指针一样的~不过在定义一个引用的时候一定要初始化.