stl废弃了<iostream.h> 而采用<iostream> 还有如:<map>,<list>,<vector>等#include<list>std::list<int> myList; //如果使用using namespace std;则可以省略std::前缀myList.insert(12); myList.insert(20); myList.insert(30);typedef std::list<int>::iterator ITER;for(ITER i = myList.begin(); i !=myList.end(); ++i) { //use i do something... }
hello1.cpp c:\hello\hello1.cpp(5) : error C2871: 'std' : does not exist or is not a namespace c:\hello\hello1.cpp(9) : error C2065: 'cout' : undeclared identifier c:\hello\hello1.cpp(9) : error C2297: '<<' : illegal, right operand has type 'char [6]' Error executing cl.exe.hello.exe - 3 error(s), 0 warning(s) 她说是这个问题我怎么解决
#include <iostream> using namespace std;
void main()
{
cout<<"hello";
}
myList.insert(20);
myList.insert(30);typedef std::list<int>::iterator ITER;for(ITER i = myList.begin(); i !=myList.end(); ++i)
{
//use i do something...
}
c:\hello\hello1.cpp(5) : error C2871: 'std' : does not exist or is not a namespace
c:\hello\hello1.cpp(9) : error C2065: 'cout' : undeclared identifier
c:\hello\hello1.cpp(9) : error C2297: '<<' : illegal, right operand has type 'char [6]'
Error executing cl.exe.hello.exe - 3 error(s), 0 warning(s)
她说是这个问题我怎么解决