猿问

执行 cl.exe 时出错,请问该怎么处理?

#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int testi;
vector<int> test;
while(cin >> testi)
test.push_back(testi);
for(vector<int>::size_type t1 = 0; t1 != test.size(); t1++){
for(vector<int>::size_type t2 = 0; t2 != test.size(); t2++){
}}
for(vector<int>::const_iterator iter1 = text.begin(); iter1 != text.end(); iter1++){
for(vector<int>::const_iterator iter2 = text.begin(); iter2 != text.end(); iter2++);
cout<< *iter1 << " " << *iter2 << " ";
}
return 0;
}

Error

F:\计算机\编程\C++\Test\try_vector_arr\s.cpp(17) : error C2065: 'text' : undeclared identifier
F:\计算机\编程\C++\Test\try_vector_arr\s.cpp(17) : error C2228: left of '.begin' must have class/struct/union type
F:\计算机\编程\C++\Test\try_vector_arr\s.cpp(17) : error C2228: left of '.end' must have class/struct/union type
F:\计算机\编程\C++\Test\try_vector_arr\s.cpp(18) : error C2228: left of '.begin' must have class/struct/union type
F:\计算机\编程\C++\Test\try_vector_arr\s.cpp(18) : error C2228: left of '.end' must have class/struct/union type
执行 cl.exe 时出错.

HUWWW
浏览 535回答 2
2回答

侃侃无极

F:\计算机\编程\C++\Test\try_vector_arr\s.cpp(17) : error C2065: 'text' : undeclared identifier第一行就指明了错误,未定义标识符 text你在前面定义的是 vector<int> test;调用的时候是 text ,哪能不出错?

潇湘沐

指针变量用 -> 访问其内部的值
随时随地看视频慕课网APP
我要回答