矢量我有一个载体命名为“列表”,我想打印在列表中的名称,但它说错误打印与名称
操作“< <”这些操作数相匹配
操作数类型是:性病:: ostream的< <的std :: string
为什么我有这个错误,我怎么CAND修复它?
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<string> list;
vector<string> getAll() { //I tried to use this function instread of "list"(list is used below) but it's the same result.
return list;
}
int main() {
list.push_back("Ion");
list.push_back("Gabi");
list.push_back("Sabrina");
for (string i : list)
std::cout << i; //HERE
}
'#include' –
有没有什么原因'vector list;'是一个全局变量? –
Borgleader
向量的名称也不好 –