注册 登录
编程论坛 C++教室

求助!一个很简单的问题!

carlbiao 发布于 2008-05-14 21:01, 1040 次点击
#include<iostream>
#include<vector>
using std::cout;
using std::cin;
using std::endl;
using std::vector;
using std::vector<int>::iterator;
int main()
{
    vector<int> CONTAINER;
    for(int i=1;i<=4;i++)
        CONTAINER.push_back(i);
    cout<<"Here is what is in the container:\n";
    iterator p;
    for(p=CONTAINER.begin();p!=CONTAINER.end();p++)
        cout<<*p<<" ";
    cout<<endl;
    cout<<"seting entries to 0:\n";
    for(p=CONTAINER.begin();p!=CONTAINER.end();p++)
        *p=0;
    for(p=CONTAINER.begin();p!=CONTAINER.end();p++)
    cout<<*p<<" ";
    cout<<endl;
    system("pause");
    return 0;
}
e:\c++ pro\标准模块库\stl向量\stl向量\vector.cpp(7) : error C2885: “std::vector<_Ty>::iterator”: 在非类范围内不是有效的using 声明
老是出现这个错误……
但是我是从书上完全打上去的
2 回复
#2
忘记喧嚣2008-05-16 13:16
我在  VC++ 2003中能运行  0错误  0警告
#3
zzy8402082008-06-06 00:47
在vc6中可能运行不了
因为using std::cout,using std::cin等等在VC6中不可用
1