Problem with inheritance in C++

Karthikeyan Ramnath karthikeyanr@subexgroup.com
Thu Apr 25 00:57:00 GMT 2002


Sir, i noticed this anamoly in the way private inheritance works in C++. I am using GCC 2.95.3
class A {
	public :
		void method() {}
}
class B : private A {
}
class C: public B {
	public:
		void mine() {
			A::method();
		}
}
void main() {
	C cc;
	cc.mine();
}
The object cc of class C is instantiated and the program runs well, while in reality it should not let me access A::method() from C as B privately inherits from A and hence it should have restricted the functionality of A.
Kindly do letme know what to do.
Thank you.
Karthikeyan.R

S/W Engineer,
Subex Systems Ltd.,
India.

DISCLAIMER: This email is bound by the terms and conditions described at
http://www.subexgroup.com/mail-disclaimer.htm




More information about the Gcc-bugs mailing list