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)
Here is program:
class MyClass
{
public:
MyClass operator+(MyClass &b)
{
return MyClass(this->value + b.value);
}
private:
int value;
};
Comments
Leave a comment