Bsp.: Externer Zugriff auf abgeleitete Klasse (public)

#include <iostream.h>

class A
{
  // wie vorher
};

class B : public A
{
  // wie vorher
};

main()
{
  B b;
  cout << b.a1 << b.a2 << b.a3 << endl;
  cout << b.b1 << b.b2 << b.b3 << endl;
}

//inh3.cc:31: member `a2' is protected
//inh3.cc:31: member `a3' is private
//inh3.cc:32: member `b2' is a protected member of class `B'
//inh3.cc:32: member `b3' is a private member of class `B'

previous up next


© 1997 Gottfried Rudorfer, C++-AG, Lehrveranstaltungen, Abteilung für Angewandte Informatik, Wirtschaftsuniversität Wien, 12/16/1998