我正在尝试创建一个地址簿,但我不断收到“expected primary expression before '&' token
”
我还希望能够编辑和创建多个地址条目!
#include <iostream>
#include <string>
using namespace std;
struct addressinfo
{
string Name;
string Address;
string Phonenumber;
};
addressinfo info;
addressinfo gna(addressinfo& info) {// get new address
addressinfo accessinfo;
info.Name;
info.Address;
info.Phonenumber;
return accessinfo;
}
void address_menu() {
int choice;
cin >> choice;
switch(choice) {
case 1:
addressinfo info = gna(addressinfo& info);
break;
}
}
int main() {
cout << "Hello world!" << endl;
}
答案 0 :(得分:7)
addressinfo info = gna(addressinfo& info)
应为addressinfo info = gna(info)
,因为您正在调用一个函数,而不是创建函数。