Is it possible to do a 'dump' on complex structures or even arrays in C++, in order to visually be able to check out what they've got inside them?
I'm thinking of something similar to print_r() or var_dump() in PHP.
Cheers, -Fin
The short answer is: no, unless you manually write such a routine yourself.
Which is often not a bad idea, but it has the usual problems of getting out of sync with the class if you are adding/changing members often. This is unavoidable because C++ lacks any form of introspection into struct
s.
If you decide to go that way, the best thing to do is to write an overload for std::ostream& operator<<(std::ostream& os, MyClass const&)
, which will enable your class to be printed to any IOStreams output stream.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With