Hey,
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:
Code:
std::cout << obj_name << std::endl;
Every possible example I can find has 2 arguments, LHS, RHS. The prototype for this system appears to only have one, the RHS.
If I add a second argument to the overloaded definition, I get:
Code:
file_name.h:53: error: `std::ostream& class_name::operator<<(std::ostream&, const class_name&)' must take exactly one argument
I put a printf inside the overloaded operator and put:
And it prints the hardcoded string literal in the operator overloading..
Does this mean I can only overload the RHS, or am I doing it wrong..
I mean I think I could do it like:
Code:
std::cout << obj << std::cout
Because it returns an ostream reference..
Additional Notes:
I didn't friend the overload, it's in the header in the class declaration.