我正在尝试连接字符串和整数,如下所示:
#include "Truck.h"
#include <string>
#include <iostream>
using namespace std;
Truck::Truck (string n, string m, int y)
{
name = n;
model = m;
year = y;
miles = 0;
}
string Truck :: toString()
{
string truckString = "Manufacturer's Name: " + name + ", Model Name: " + model + ", Model Year: " + year ", Miles: " + miles;
return truckString;
}
我收到此错误:
error: invalid operands to binary expression ('basic_string<char, std::char_traits<char>, std::allocator<char> >'
and 'int')
string truckString = "Manufacturer's Name: " + name + ", Model Name: " + model + ", Model Year: " + year ", Miles...
有什么想法我可能做错了吗?我是 C++ 新手。