Hi.
How can I print bytes of an arbitrary object? I don't know anything about it's size. for example object is a class or a struct that I defined it.
For Example:
1 2 3 4 5 6 7 8 9 10
struct MY_STRUCT
{
int a, b;
};
template <class T>
void print(T number); // <- This prints object T, bytes with 0 and 1
// for example: 01010101 10001000 00010001 00010001
// => a = 01010101 10001000
// b = 00010001 00010001
You realize also that this is most likely to be entirely useless information. The byte-structure of a class has relatively few caveats placed upon it -- meaning the compiler can do stuff you wouldn't expect.
Besides endianness issues, there is also padding, vtables, and, in some cases, ordering issues.