有關於Vector對象的問題


這是《C++ primer》第四版上的一個例子,向vector添加元素,使用push_back函數,我按照書上給出的樣例程序,在VC6.0裏編了一下,如下:
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
     string word;
     vector<string> text;
     while(cin>>word){
          text.push_back(word);
      }
     cout<<text<<endl;
     return 0;
}

編譯時出現一個錯誤,如下:
 error C2679: binary '<<' : no operator defined which takes a right-hand operand of type 'class std::vector<class
std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<cla
ss std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >' (or there is no acceptable conversion)

大概的意思是說cout<<text<<endl這一行有錯誤。請問是爲什麼呢?

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章