Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
你好,我是 C++ 新手,我收到了这个错误。IntelliSense:没有运算符“+”匹配这些操作数 有问题的代码行是:
cout << i << "\t" << temp->VehicleNo + "\n";
链接到显示错误上下文的图片
http://i.imgur.com/IgKHn.jpg
所以,temp->VehicleNo是类的对象,Vehicle这个类有一个VehicleNo类型的成员std::string。要显示该字符串,您需要以下代码:
temp->VehicleNo
Vehicle
VehicleNo
std::string
cout << i << "\t" << temp->VehicleNo.VehicleNo << "\n";
我建议您将其重命名Node::VehicleNo为Node::Vehicle,以便在上面的代码中为temp->Vehicle.VehicleNo,这更有意义。
Node::VehicleNo
Node::Vehicle
temp->Vehicle.VehicleNo