Greetings.

While playing with D code (http://dpaste.dzfl.pl/c6d9e5bd) I noticed that I have no idea how to write equivalent to this C++ code:

http://dpaste.dzfl.pl/ae182695 *[1]

Could somebody point me out how to achieve same thing? Maybe I am missing something obvious? Thanks!

*[1] - code for lazy people :
#include <cstdio>

class A
{
        int x;

public:
        A(int y) : x(y){}

        void foo()
        {
                printf("::foo(), x: %d\n", x);
        }
};

class B : public A
{
public:
        B(int y) : A(y)
        {}              
};

int main(void)
{
        void (A::*fp)() = &A::foo;

        A a(3);
        B b(4);

        (a.*fp)();
        (b.*fp)();

        return 0;
}

Reply via email to