Question #36399

Consider a Fruit Basket class with no. of Apples and no. of Mangoes as data members. Overload the ‘+’ operator to add two objects of this class.
1

Expert's answer

2013-10-31T13:42:06-0400

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;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS