I've been trying to figure out how to add a private member from Object A, to a private member from Object B.
Both Apples and Mangoes Class's inheritance from the base class Fruits. I have a thrid class 'MyClass', that I want to inheritance the private members of the Apples and mangoes class. So in MyClass, I have a friend function to overload the + operator. The friend function is defined as follows:
MyClass operator+(const Apples &dObj, const Dogs &cObj); I want to access dObj.age and cObj.age within the above function, invoke by this statement in main:
mObj = dObj + cObj;
Comments