-2
我想cout
我載體之一的內容在下面的程序:C++誤差「<<」操作符(來清點向量的內容)
#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;
}
每當我嘗試編譯這個我得到這個錯誤:
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
運算符<<
的錯誤是什麼?
右邊的矢量沒有'<<'運算符。你期望看到什麼輸出? –
看看http://stackoverflow.com/questions/10750057/c-printing-out-the-contents-of-a-vector沒有現成的重載操作符爲std :: vector –