Bsp.: Public Vererbung

#include <iostream.h>

class A
{
  // wie vorher
};

class B : public A
{
public:
  int b1;
  B() { 
    b1 = b2 = b3 = 0; 
    a1 = a2 = a3 = 1;
  }
protected:
  int b2;
private:
  int b3;
};


main()
{
  A a;
  cout << a.a1 << a.a2 << a.a3 << endl;
}

//inh2.cc: In method `B::B()':
//inh2.cc:20: member `a3' is private

previous up next


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