I want to create an arrays pointing to the members of an object, something like this:

// der1, der2, der3 or derived object of base

class myobject{
    der1 * d1;
    der2 * d2
    der3 * d3

    void do_op(){ *d3=*d1 + *d2;} // this must remain as time-efficient as possible

    typedef base * myobject::*member;
    static member myarray[3]; // eventually initialised to {&myobject::d1, &myobject::d2, &myobject::d3}

Unfortunately this won't work because der1 won't convert automatically to base * in this context

The reason I wan't to this this is to be able to scan through all the members of myobject easily (including sub-trees where der1 is similar to myobject).

Anybody knows how to do this (or a close equivalent) that still would be efficient?

Instead of

*d3=*d1 + *d2;

I would try:

base temp; temp=*d1+*d2;(base&)(*d3)=temp;

Or maybe just: