I don't understand why this code gives me error
void printSalesFile(vector< vector<float> > & list)
{
ofstream outfile;
outfile.open("sales.lst", ios::out);
if (outfile.is_open())
{
outfile << setw(6) << right << "ID"
<< setw(12) << "January"
<< setw(12) << "Febuary"
<< setw(12) << "March"
<< setw(12) << "April"
<< setw(12) << "May"
<< setw(12) << "June"
<< setw(12) << "July"
<< setw(12) << "August"
<< setw(12) << "September"
<< setw(12) << "October"
<< setw(12) << "November"
<< setw(12) << "December" << endl;
for (unsigned int i = 0; i <= list.size(); i++)
{
outfile << setw(6) << right << list[i]; //i don't understand why it says there's an error here.
for(int j = 0; j <= 11; j++)
outfile << setw(12) << right << list[i][j];
outfile << endl;
}
}
outfile.close();
}
I have tried deleting it and pasting the things I wrote above that works but still get the errors.
Here is the error message:
D:\QT\Salesperson\main.cpp:295: error: cannot bind 'std::basic_ostream<char>' lvalue to 'std::basic_ostream<char>&&'
outfile << setw(6) << list[i];
^
As for the text file, it has 2 lines, 1 for the header and another that has values all set to 0