I'm working on a Solaris box and trying to overload the left bitshift operator as a "print" function in an object I have, so I can do:
Every possible example I can find has 2 arguments, LHS, RHS. The prototype for this system appears to only have one, the RHS.Code:std::cout << obj_name << std::endl;
If I add a second argument to the overloaded definition, I get:
I put a printf inside the overloaded operator and put:Code:file_name.h:53: error: `std::ostream& class_name::operator<<(std::ostream&, const class_name&)' must take exactly one argument
And it prints the hardcoded string literal in the operator overloading..Code:obj << std::cout;
Does this mean I can only overload the RHS, or am I doing it wrong..
I mean I think I could do it like:
Because it returns an ostream reference..Code:std::cout << obj << std::cout
I didn't friend the overload, it's in the header in the class declaration.