1.5 1.5_5

Kai Ge

New Member
Hi, there. I'm encountering a problem with this exercise. I created shape.hpp and iodevice.hpp, defined both functions(display(), and void operator(Circle/Line& ) as pure virtual, I also passed the forward deceleration problem by only including one header file. but when it comes to defining in Shape class, display(IODevice& iodevice)const override{ iodevice<<*this), it returns the error of "binary '<<': 'IODevice' does not define this operator or a conversion to a type acceptable to the predefined operator". Can you tell me why is this happening and what can I do about it? Thank you.
 

APalley

Well-Known Member
Hi, there. I'm encountering a problem with this exercise. I created shape.hpp and iodevice.hpp, defined both functions(display(), and void operator(Circle/Line& ) as pure virtual, I also passed the forward deceleration problem by only including one header file. but when it comes to defining in Shape class, display(IODevice& iodevice)const override{ iodevice<<*this), it returns the error of "binary '<<': 'IODevice' does not define this operator or a conversion to a type acceptable to the predefined operator". Can you tell me why is this happening and what can I do about it? Thank you.
Did you overload operator<< for the device?
 

Kai Ge

New Member
Did you overload operator<< for the device?
It's not showing any error when its not compiled but when I put cursor above "<<" it did say +1 overload, is that what you mean by overload?
I thought a function is overloaded when the same name is used but function with different types of argument are created.
 

APalley

Well-Known Member
It's not showing any error when its not compiled but when I put cursor above "<<" it did say +1 overload, is that what you mean by overload?
I thought a function is overloaded when the same name is used but function with different types of argument are created.
In this context, it just means that you defined a version of the operator for this class type
 
Top