Hi, I'm trying to pas ostream object as a parameter to my function,
and I get this error.
here is my function
1 2 3 4 5 6 7 8 9 10 11 12
void printTask(int op1, int op2, int len, char operation, std::ostream& os)
{
os << endl << " " << setw(len) << op1 << endl;
os << operation << " " << setw(len) << op2 << endl;
os << "-------------" << endl;
os << " ";
for(int i = 0; i < len; i++)
{
os << "?";
}
os << endl;
}
and how I call it
1 2 3 4
printTask(op1, op2, answer_lengts, '+', file);
printTask(op1, op2, answer_lengts, '+', cout);
//first 4 parameters are OK, first 3 are int's and 4th is char. 'file' is of type fstream
//fstream file("output.txt", ios::out);
Can anyone offer some help please?
EDIT:
I know that ostream can't have copy constructor, so that is why I'm trying to pass by reference...
I even tried to go with default parameter: void printTask(int op1, int op2, int len, char operation, ostream& os = cout)