Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!mcsun!sunic!bmc!kuling!fredriks From: fredriks@kuling.UUCP (Fredrik Stax{ng) Newsgroups: comp.lang.c++ Subject: Pointers to member functions. Message-ID: <1285@kuling.UUCP> Date: 11 Dec 89 18:55:24 GMT Organization: DoCS, Uppsala University, Sweden Lines: 50 I think the following piece of code would work. In The C++ Language Reference Manual 2.0 sec 5.4 it says: Pointer to member may be explicitly converted ... when the two type are pointers to member functions of classes derived from each other. However my C++ compiler refuses to compile this (error: cast to member). It is HCR C++ ver 2.01. Is this supposed to work? If not, why not? (I know it is unsafe, but it would be very un-C to disallow it because of that.) class Base { public: void Error() ; } ; typedef void (Base::*PMemF)() ; class Derived: public Base { public: void F1() ; } ; main() { PMemF P3 ; P3 = (PMemF)(Derived::F1) ; } Fredrik Stax{ng | C looks like a mix of Algol and TECO. CS Student@Uppsala University | -- KPJ Jaakkola fredriks@kuling.docs.uu.se | - -- Fredrik Stax{ng | C looks like a mix of Algol and TECO. CS Student@Uppsala University | -- KPJ Jaakkola fredriks@kuling.docs.uu.se |