178k views
0 votes
Implement a class MyInt() that behaves almost the same as the class int, except when trying to add an object of type MyInt. Then, this strange behavior occurs____________.

1 Answer

3 votes

Answer:

Implement a class MyInt() that behaves almost the same as the class int, except when trying to add an object of type MyInt. Then, this strange behavior occurs.

>>> x = myInt(5)

>>> x * 4

20

>>> x * (4 + 6)

50

>>> x + 6

11

User Simhor
by
4.4k points