因此,我开始编写代码,然后测试是否还记得如何投射,直到我的运算符下方出现一条红线。 这是编译器错误:插入运算符不与矢量一起工作,我不知道为什么
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ł包含标题 –