In class A, I have the friend function, and use it to print out the private instance variable a.Code:class A { private: int a; punlic: friend ostream & operator<<(ostream &os, const A &object); }; ostream & operator<<(ostream &os, const A &object) { os << object.a; return osl; } class B: public class A { public: freind ostream & operator<<(ostream &os, const B &object) { os << object.a ; } };
Now, in class B, I would like to print out the variable a, which is inherited from class A, but I get an error when I try objcet.a, in class B, How can I access the variable a, using the friend function in class B?
Thanks