#include #include "family.h" using namespace std; inline void add(const void *& p, ptrdiff_t diff) { p = static_cast(p) + diff; } void print(const mother *m) { const void *p = m; cout << "\nThis mother starts at address " << p << ".\n"; const ptrdiff_t *const pd = *reinterpret_cast(p); const ptrdiff_t diff = *pd; cout << p << ": " << pd << " (pointer to table)\n" << pd << ": " << diff << " (offset)\n"; add(p, sizeof (ptrdiff_t **)); cout << p << ": " << *reinterpret_cast(p) << " (mother::j)\n"; add(p, sizeof (int)); cout << p << " is the address of the first byte after the mother.\n" << "The mother's grandparent starts at address " << p; if (diff < 1000) { cout << " + " << diff << " == "; add(p, diff); cout << p; } cout << ".\n" << p << ": " << *reinterpret_cast(p) << " (grandparent::i)\n"; }