Apr-21-2019, 07:24 PM
(This post was last modified: Apr-21-2019, 07:24 PM by ichabod801.)
Writing an add method does not override the + operator. You need to write an __add__ method (with two underscores before and after the name, this is called a dunder method). The parameters of the method will be self and other. So if you have two objects of the class C1 and C2, and do C1 + C2, that will call C1.__add__(C2), with C1 automatically assigned to the self parameter and C2 assigned to the other parameter.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures