Question #314098

Write a C++ program to overload the + and – operators to find the sum and difference of two instances of Time class having members as hour, minute and second. (Use member function for one and friend function for other)


Expert's answer

Here is program:

class MyClass
{
public:
	MyClass operator+(MyClass &b)
	{
		return MyClass(this->value + b.value);
	}
private:
	int value;
};
LATEST TUTORIALS
APPROVED BY CLIENTS