Small question , can you help me ??
Hi for ever :)
I am asking about :
How to addition two object with different type and then store the result in the object have same type of one of these two object
by using operator overloading ?
for example :
we have class called ThreeD
Code:
ThreeD operator +(ThreeD op1, ThreeD op2)
{
ThreeD result = new ThreeD();
/* This adds together the coordinates of the two points
and returns the result. */
result.x = op1.x + op2.x;
result.y = op1.y + op2.y;
result.z = op1.z + op2.z;
return result;
}
in these example we add two object of same type in the same class
What about if I have two classes
and I wanted to add object from class 1 to object from class 2
and then store the result in objcet of type of class 1
Thats all ,
thanks to reed my question ,
I wait the answer :)