矢量我有一個載體命名爲「列表」,我想打印在列表中的名稱,但它說錯誤打印與名稱
操作「< <」這些操作數相匹配
操作數類型是:性病:: 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
向量的名稱也不好 –