独孤剑魔 发表于 2008-8-9 10:21

vector::const_iterator

#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)

xlh5225 发表于 2008-8-9 10:25

加一个头文件:#include<string>

独孤剑魔 发表于 2008-8-9 10:26

感谢!

页: [1]

编程论坛