#include <iostream>
using namespace std;
struct Person {
string first_name;
string last_name;
};
int main() {
Person a;
a.first_name = "foo";
a.last_name = "bar";
cout << a.first_name << " " << a.last_name;
return 0;
}
給出錯誤:打印結構成員
binary '<<' : no operator found which takes a right-hand operand of
type 'std::string' (or there is no acceptable conversion)
爲什麼會發生?
'的#include' –
101010
你缺少的#include''。 –