OneCompiler

== Overloading

#include <iostream>
using namespace std;
class Time {

private:
int hour;
int minute;

public:
Time(int hour = 0, int minute = 0) : hour(hour), minute(minute) {}

bool operator==(const Time& other) const {
    return hour == other.hour && minute == other.minute;
}

friend std::ostream& operator<<(std::ostream& os, const Time& time) {
    return os << time.hour << ":" << time.minute;
}

};

int main() {
Time t1(10, 30);
Time t2(10, 30);

if (t1 == t2) {
    std::cout << "t1 and t2 are equal." << std::endl;
} else {
    std::cout << "t1 and t2 are not equal." << std::endl;
}

}