Quiz on Operator Overloading

Here is a quiz to test your understanding of the concepts related to operator overloading.

1

Consider the following code:

struct Duration {
    int hour;
    int minute;
    bool opEquals(Duration rhs) const {
        return hour == rhs.hour; 
    }
}

void main() {
    assert(TimeOfDay(20, 30) == TimeOfDay(20, 21));
}

Will the assert pass?

A)

Yes

B)

No

Question 1 of 50 attempted

Get hands-on with 1200+ tech skills courses.