A
akiriwas
The subject basically says what I am having trouble with. For an
example lets say I have a class A which has a function f. I then also
have a class B which inherits from A and has a function g.
class A
{
public: void f(int,float);
};
class B : public A
{
public: void g(int, float);
};
Okay, now with all that setup, if I created a pointer to a member
function something like this:
typedef void (A::*MFP)(int a, float b);
if I then use it such as
MFP mfp = &A::f;
then everything works fine.
even if I do:
MFP mfp2 = &B::f;
then everything still works (presumably because f is not defined in B
and must then be from A). However, if I try this:
MFP mfp3 = &B::g;
then it complains that B::g is not of the right type since it is not a
member function of class A. The protype signature is the same, both
(int, float), is there no way to make this work? It seemed to me that
it should have worked since any instance of B is still by definition an
instance of A. Anyone done anything like this?
-akiriwas
example lets say I have a class A which has a function f. I then also
have a class B which inherits from A and has a function g.
class A
{
public: void f(int,float);
};
class B : public A
{
public: void g(int, float);
};
Okay, now with all that setup, if I created a pointer to a member
function something like this:
typedef void (A::*MFP)(int a, float b);
if I then use it such as
MFP mfp = &A::f;
then everything works fine.
even if I do:
MFP mfp2 = &B::f;
then everything still works (presumably because f is not defined in B
and must then be from A). However, if I try this:
MFP mfp3 = &B::g;
then it complains that B::g is not of the right type since it is not a
member function of class A. The protype signature is the same, both
(int, float), is there no way to make this work? It seemed to me that
it should have worked since any instance of B is still by definition an
instance of A. Anyone done anything like this?
-akiriwas