Regression with pmfs??

Klaus-Georg Adams Klaus-Georg.Adams@chemie.uni-karlsruhe.de
Tue Oct 27 04:02:00 GMT 1998


>>>>> "Theodore" == Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr> writes:

    Theodore> Yes, but B::A1 should work right ? Since B inherits
    Theodore> publicly from A. But that does not work.. (I wanted to
    Theodore> say also that in the note but forgot). Am I still
    Theodore> missing something ?

It works for me. The following example compiles:

struct a { void f() {} };
struct b : a {};

int main()
{
	void (b::*pmf)() = &b::f;
	b theb;
	(theb.*pmf)();
}

and your example compiles as well, if modified accordingly:

class A {
public:
    A()  { }
    ~A() { }
    const double A1() const { return 1.0; }
    const double A2() const { return 2.0; }
};

class B: public A {
public:

    B() { }
    ~B() { }
    double R(const int) const;
};

double
B::R(const int i) const
{
        typedef const double (B::*Func)() const;
        const Func D1 = &B::A1;
        const Func D2 = &B::A2;
        const Func DD = (i==2) ? &B::A1: &B::A2;
        return (this->*DD)();
}

This is with GNU C++ version egcs-2.92.17 19981026.

-- kga
-------------------------------------------------------------------------
Klaus-Georg Adams        Email: Klaus-Georg.Adams@chemie.uni-karlsruhe.de
Institut f. Anorg. Chemie, Lehrstuhl II            Tel: 49(0)721 608 3485
Universität Karlsruhe, D-76128 Karlsruhe
-------------------------------------------------------------------------



More information about the Gcc-bugs mailing list