'<<'运算符的C++错误(对cout的向量内容)

-2 c++ c++11

我想cout在以下简单程序中的一个向量的内容:

#include<iostream>
#include<ios>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

int main()
{
    string name;
    double median;
    int x;
    vector<double> numb, quartile1, quartile2, quartile3, quartile4;

    cout << "Please start entering the numbers" << endl;
    while (cin >> x)
    {
        numb.push_back(x);
    }

    int size = numb.size();
    sort(numb.begin(), numb.end());
    for (int i = 0; i < size; i++)
    {
        double y = numb[(size / 4) - i];
        quartile1.push_back(y);
    }
    cout << quartile1; // Error here
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

每当我尝试编译这个时,我都会收到此错误:

Error   1   error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::vector<double,std::allocator<_Ty>>'
(or there is no acceptable conversion)
c:\users\hamza\documents\visual studio 2013\projects\project1\project1\source.cpp   30  1   Project1

2   IntelliSense: no operator "<<" matches these operands
operand types are: std::ostream << std::vector<double, std::allocator<double>>  
c:\Users\Hamza\Documents\Visual Studio 2013\Projects\Project1\Project1\Source.cpp   29  7   Project1
Run Code Online (Sandbox Code Playgroud)

<<操作员的错误是什么?

vuk*_*ung 5

您可以cout使用std::copy以下内容发送整个矢量的内容:

copy(quartile1.begin(), quartile1.end(), ostream_iterator<double>(cout, ", "));
Run Code Online (Sandbox Code Playgroud)

请注意,您需要

#include<iterator>
Run Code Online (Sandbox Code Playgroud)

为了那个原因.