I want to overload << operator in a Line class so I can print an object using cout like this:
cout << myLineObject << endl;
but this is not working:
class Line{
public:
float m;
float b;
string operator << (Line &line){return ("y = " + line.m + "x + " + line.b);};
};
I get:
Invalid operands of types 'const char [5]' and 'float' to binary 'operator+'
I also tried with stringstream
but I get even more errors. What is the correct way of doing this?
Thanks ;)