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

vector::const_iterator

独孤剑魔 发布于 2008-08-09 10:21, 1164 次点击
#include<iostream>
#include<vector>
using namespace std;
void main()
{
    vector<string> text(10,"abc");
    for(vector<string>::const_iterator iter = text.begin();iter!=text.end();iter++)
    {
        cout<<*iter<<endl;
    }
}

编译无法通过
--------------------Configuration: fafafad - Win32 Debug--------------------
Compiling...
fafa.cpp
D:\c++\fafafad\fafa.cpp(9) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conv
ersion)
Error executing cl.exe.

fafafad.exe - 1 error(s), 0 warning(s)
2 回复
#2
xlh52252008-08-09 10:25
加一个头文件:#include<string>
#3
独孤剑魔2008-08-09 10:26
感谢!
1