我正在学习 C++ 中的引用。是否无法创建对结构数组的引用?
struct student {
char name[20];
char address[50];
char id_no[10];
};
int main() {
student test;
student addressbook[100];
student &test = addressbook; //This does not work
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
类型“student &”(非 const 限定)的引用无法使用类型“student [100]”的值进行初始化错误
C2440“初始化”:无法从“student [100]”转换为“student &”