-2
行「list listObject;」是說不允許char和listObject不能識別。有人能給我一個線索,說我做錯了什麼嗎? 謝謝創建矢量方法
char list;
vector<char> v(20);
list<char> listObject;
int i;
for (i = 0; i < 20; i++)
v[i] = 'A' + i;
cout << "Original contents of vector:\n";
for (i = 0; i < v.size(); i++)
cout << v[i] << " ";
cout << "\n\n";
char str[] = "-TEST MESSAGE-";
for (i = 0; str[i]; i++)
listObject.push_back(str[i]);
copy(listObject.begin(), listObject.end(), v.begin());
// display result
cout << "Contents of vector after copy:\n";
for (i = 0; i < v.size(); i++)
cout << v[i] << " ";
你定義一個名爲'list'一個'char',然後嘗試定義類型'list'的對象。 – owacoder
(除非你拿出'using namespace std;'你顯然有某個地方) –
這個矢量方法在哪裏創建? – juanchopanza