2 // GROUPS passed visibility
4 // From: Gordon Joly <G.Joly@cs.ucl.ac.uk>
5 // Date: Wed, 21 Apr 93 09:42:07 +0100
6 // Subject: /*** BUG REPORT : THE MYTH OF PRIVATE INHERITANCE ***/
7 // Message-ID: <9304210842.AA01815@life.ai.mit.edu>
18 virtual void Number(int c)
19 { number = c; } // ERROR - private
21 { return number; } // ERROR - private
28 B(int c, int i) : second_number(c), A(i)
33 virtual void firstNumber(int b) // renames member function Number(int) of class A
35 virtual int firstNumber() // renames member function Number() of class A
36 { return A::Number(); }
46 C(B* bp) : bobject(bp)
51 // the following two functions access
52 // private member functions of class B
53 // and they should not be able to do so
55 virtual void setBValue(int i)
56 { if (bobject) bobject->Number(i); }// ERROR - .*
57 virtual int getBValue()
58 { if (bobject) { return bobject->Number(); } return 0; }// ERROR - .*
64 B* bobject = new B(2, 1);
65 C* cobject = new C(bobject);
66 cobject->setBValue(8);
67 std::cout << cobject->getBValue() << std::endl;