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/01 08:24:38
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.
简单的说就是一个“别名”而已~比如罗纳尔多,又叫做胖罗,肥罗,外星人,都是指一个人,罗纳尔多进球了就等于是胖罗,肥罗,外星人进球了~行为跟指针一样的~不过在定义一个引用的时候一定要初始化.