🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by loepere Mon, 19 Jun 1989 21:50
derivation and pointers to members
#69
Author: loepere
Date: Mon, 19 Jun 1989 21:50
41 lines
1435 bytes
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);
}
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads