Hello.
I have 3 classes. B and C inherit from A. I want that class B will be able to call functions of C, so I tried to do this:
but i get an error:Code:class A { public: A(int b=0) {a=b;} protected: void Print() {cout<<"Hello world"<<endl;} private: int a; }; class B: public A { public: B(int b=0): A(b){} void Do(A& a) {a.Print();} //error }; class C: public A { C(int b=0): A(b){} int c; };
error: `virtual void A::Print()' is protected.
How can I do it without using "friend" (and without making Print public) ?




Reply With Quote