Pointer-to-member-function pointing to a member function of an inherited class
akiriwas_at_gmail.com
Date: 01/29/05
- Next message: lmanchur.: "stl c++ & map"
- Previous message: Scott McPhillips [MVP]: "Re: class instances and threads"
- Next in thread: Gianni Mariani: "Re: Pointer-to-member-function pointing to a member function of an inherited class"
- Reply: Gianni Mariani: "Re: Pointer-to-member-function pointing to a member function of an inherited class"
- Reply: Mike Wahler: "Re: Pointer-to-member-function pointing to a member function of an inherited class"
- Reply: Matthew Schaefer: "Re: Pointer-to-member-function pointing to a member function of an inherited class"
- Reply: Shezan Baig: "Re: Pointer-to-member-function pointing to a member function of an inherited class"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Jan 2005 13:05:09 -0800
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
- Next message: lmanchur.: "stl c++ & map"
- Previous message: Scott McPhillips [MVP]: "Re: class instances and threads"
- Next in thread: Gianni Mariani: "Re: Pointer-to-member-function pointing to a member function of an inherited class"
- Reply: Gianni Mariani: "Re: Pointer-to-member-function pointing to a member function of an inherited class"
- Reply: Mike Wahler: "Re: Pointer-to-member-function pointing to a member function of an inherited class"
- Reply: Matthew Schaefer: "Re: Pointer-to-member-function pointing to a member function of an inherited class"
- Reply: Shezan Baig: "Re: Pointer-to-member-function pointing to a member function of an inherited class"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|