All my classes implement a dump member function, e.g.:
struct A {
template
std::basic_ostream &
Generally this would be the advisable way, IMO:
struct A {
int x = 5;
friend std::ostream & operator<<(std::ostream &os, const A& a){
return (os << a.x);
}
};
Reason: 'friend' functions and << operator overloading: What is the proper way to overload an operator for a class?
If you really want to have a dedicated dump method, you could define a base class "collecting" dumpable objects.