0
Hi guys, I'm trying to overload the "<<" operator but I keep getting an error that says "too many parameters"
2 Respostas
+ 1
You didn't overload it. You *made* operator << for your class. That's because you define them as *member functions*. Because they are binary operators and member functions, they can only accept one operator. To overload <<, make them as friend function and define them outside of the class.
0
You forgot to add the 'friend' keyword in front of the operator>> and operator<< function declaration.
Then, in the definition remove the Rectangle:: part because friend functions are not part of the actual class, they don't have access to 'this'.
Also you have 1 operator<< with an incorrect signature and you're not returning anything which might result in a crash.