Topic: Dereferencing virtual member function pointers : help
Author: gbs@comp.lancs.ac.uk (Gareth Smith)
Date: Thu, 27 May 1993 17:20:17 GMT Raw View
I have two classes, A and B. A is B's superclass. I want to store a pointer
to a member function in B within A. How do I dereference the function
pointer in A without knowing B's type.
ie .
Everything is Public:
class A {
void (A::*memberfn)(int);
virtual void working(int);
};
class B : public A {
void working(int);
};
B::B() or A::A()
{ {
memberfn=working; memberfn=working;
} }
When I call working, it's the one defined by class A.
In my code I have more than class B being derived from A. And memberfn is
an array - (void (A::*memberfn[10](int);
Can anyone help? I tried loosing the first A giving -
void (::*memberfn)(int);
But the compiler didn't like that.
I'm currently using gcc 2.3.3, but I didn't get anywhere with AT&T CC V2.
Thanks in advance for any information.
Gareth
__________________________________________________________________
Gareth Smith \ Department of Computing, SECAMS,
gbs@comp.lancs.ac.uk \ Lancaster University,
\ Bailrigg, Lancaster, LA1 4YR , U.K.
FAX:+44 (0)524 381707 \ PHONE:+44 (0)524 65201 Ex3793