For example, if I wanted to have a default version of outputting with << and a detailed version.
myClass myObject(//Constructor parameters);
cout << myObject << "\n";
cout << myObject.detailed << "\n";
I tried making a modifier within my class but that didn't seem to work.
class myClass {
public:
friend std::ostream& operator<<(std::ostream& output, const myClass& myObject);
std::ostream& detailed(std::ostream& output);
}
That gave the error "Reference to non-static member function must be called".
I think my approach is the same as what @RemyLebeau but more generic.