Changes

Jump to: navigation, search

Rchan sandbox

6 bytes added, 18:59, 3 November 2019
Part 3 - Operator overloading
: Changing or specifying the behaviour of an operator so that it works with programmer-defined types is called '''operator overloading'''.
: Let's add the appropriate code to the __add__ function to overload the '+' operator so that we can use an arithmetic expression to tell the python interpreter to add two time object.
::* '''Associate the following code to the __add__ method for Time class in lab7d.py''':<source lang="python">
def __add__(self, t2):
return self.sum_times(t2)
1,760
edits

Navigation menu