Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!westford.ccur.com!loepere From: loepere@westford.ccur.com Newsgroups: gnu.g++.bug Subject: derivation and pointers to members Message-ID: <8906192157.AA23895@uunet.uu.net> Date: 19 Jun 89 21:50:13 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 41 In "Pointers to Class Members in C++" (1988 USENIX C++ Conference) it is claimed that a value of type "pointer to member" for a base class can be assigned to a variable of type "pointer to member" for a class derived from that base. This does not seem to work (1.34). - Keith #include class hospital_room { public: int room_no; int patient_id; inline hospital_room (const int a_room_no, const int a_patient_id) { room_no = a_room_no; patient_id = a_patient_id; } }; class maternity_room : public hospital_room { public: int baby_patient_id; inline maternity_room (const int a_room_no, const int a_patient_id, const int a_baby_patient_id) : hospital_room (a_room_no, a_patient_id) { baby_patient_id = a_baby_patient_id; } }; int main () { maternity_room room123 (123, 123456, 1234567); typedef int (maternity_room::*derived_ptr_t); derived_ptr_t maternity_room_no_p = &hospital_room::room_no; cout << (room123.*maternity_room_no_p); }