Bsp.: Externer Zugriff auf Objekte einer Klasse

#include <iostream.h>

class A
{
public:
  int a1;
  A() { a1 = a2 = a3 = 0; }
protected:
  int a2;
private:
  int a3;
};

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

//inh1.cc: In function `int main()':
//inh1.cc:18: member `a2' is a protected member of class `A'
//inh1.cc:18: member `a3' is a private member of class `A'

previous up next


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