gpt4 book ai didi

c++ - ‘&’ token 之前的预期初始值设定项

转载 作者:搜寻专家 更新时间:2023-10-31 01:05:20 28 4
gpt4 key购买 nike

<分区>

我写了一个简单的例子,来自《The C++ Programming.Language.4th.Edition》这本书

#include <ostream>

struct Entry{
string name;
int number;
}

ostream& operator<<(ostream& os, const Entry& e){
return os << "{\"" << e.name << "\"," << e.number << "}";
}

int main()
{
Entry a;
a.name = "Alan";
a.number = "12345";
return 0;
}

g++编译时返回错误信息错误:“&”标记之前的预期初始值设定项

ps:上面提到的&token属于ostream&算子

谁能给个线索?

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com