I overloaded the << operator of a class. How do I have to overload the operator if I want to use it on pointers, like the following?
class A {
std::string operator<<(std::string&);
}
aInst << "This works";
aPointer << "This doesnt work";
aPointer->operator<<("Whereas this works but is useless");
I hope you can help me.
heinrich
You need to dereference the pointer first.
The only other way is the way you described above
Edit: Andre’s solution below is workable as well, but like he said it may not be a good idea.