loepere@westford.ccur.com (06/20/89)
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 <stream.h>
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);
}