// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <cstdint>

using namespace std;

typedef void (*fptr)(void *p);

void vdump(void *p, int n)
{
    fptr *f = *((fptr **)p);
    for(int i = 0; i < n; i++)
    {
        f[i](p);
    }
}

class A
{
private:
    int32_t v1;
    int32_t v2;
public:
    A(int32_t v1, int32_t v2) { this->v1 = v1; this->v2 = v2; }
    void dump() { cout << "A:" << endl << (int64_t)this << endl <<  (int64_t)&v1 << endl << (int64_t)&v2 << endl; }
};

class B
{
private:
    int32_t v1;
    int32_t v2;
public:
    B(int32_t v1, int32_t v2) { this->v1 = v1; this->v2 = v2; }
    virtual void dump() { cout << "B:" << endl << (int64_t)this << endl <<  (int64_t)&v1 << endl << (int64_t)&v2 << endl; }
};

class abC
{
private:
    int32_t v1;
    int32_t v2;
public:
    abC(int32_t v1, int32_t v2) { this->v1 = v1; this->v2 = v2; }
    virtual void dump() { cout << "C:" << endl << (int64_t)this << endl <<  (int64_t)&v1 << endl << (int64_t)&v2 << endl; }
    virtual void f1() = 0;
    virtual void f2() = 0;
};

class C : public abC
{
public:
   C(int32_t v1, int32_t v2) : abC(v1, v2) { }   
   void f1() { cout << "f1" << endl; }
   void f2() { cout << "f2" << endl; }
};

int main()
{
    A a(123, 456);
    a.dump();
    vdump(&a, 0);
    B b(123, 456);
    b.dump();
    vdump(&b, 1);
    C c(123, 456);
    c.dump();
    vdump(&c, 3);
    return 0;
}
