因此,我開始編寫代碼,然後測試是否還記得如何投射,直到我的運算符下方出現一條紅線。 這是編譯器錯誤:插入運算符不與矢量一起工作,我不知道爲什麼
Error C2679: binary '<<': no operator found which takes a right-hand operand of type 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' (or there is no acceptable conversion) (12)
老實說,我從未有過的問題輸出字符串/矢量,所以我不知道如何解決這個問題。有人可以告訴我如何解決這個問題。如果你能告訴我代碼出了什麼問題,那也會很棒。
#include "stdafx.h"
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector<string>hello;
hello.push_back("9");
for (auto i : hello)
cout << i << " "; <-- The first operator is underlined. Why?
return 0;
}
這是C++,不包含C標籤! – tilz0R
嘗試包括'' –
@JakubGaweł包含標題 –