0% found this document useful (0 votes)
7 views3 pages

Operator Oveloading

The document outlines various methods and classes related to operator overloading in programming, focusing on addition and subtraction operations. It includes examples of class definitions and methods for handling custom behaviors in mathematical operations. Additionally, it discusses equality comparison and object representation in the context of operator overloading.

Uploaded by

ck2575447
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Operator Oveloading

The document outlines various methods and classes related to operator overloading in programming, focusing on addition and subtraction operations. It includes examples of class definitions and methods for handling custom behaviors in mathematical operations. Additionally, it discusses equality comparison and object representation in the context of operator overloading.

Uploaded by

ck2575447
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

opexador

ie Opesator, Londing. memdiom


respetie
to be over loaclod in
Tyhon.
over loadinay me an
behawio opoadore bod
operosd, thot dey
(ouide admdod beyond dhiy
Drediine d opeo atienal meanivy).
Tie op adergi -add -Sub
print
Additioml (t)
medho d: -- add (sell, dher)
his method uyed do over Coad thho
+ operoator to dyint Cwstom addition.

clas addidion
det --init -- (ses, x, y:

det --add-(Se, odher)i


return addihon ( Beldx + odher.x
VI addi dion (3,3)
V2
VI+ V2
Bub ha thiorn(-)
metto d -- Sab- (se), oter)
-5 his medlso is wed to over oad dha
dele Subbsachio, be ut'or
do
clas poi vt
det ini(
iniialige
det -- Sub --

retun point sel. n - odkr.x


Sey- odher. y)
PI SPbint (s,)
P2 >point (2,3)
wes due Subme dho d

Eauality (= =)
medod -- Cy--(sel otun
wsed to overloao e
opesada do dayine Cuutm e aualidy
Compar ison behayior.
Ex clas Book
oleinit-()
#init teucho
deti--ey--(sel, oda):

b Book
b2 = Book
&hing Repekmtation (str (o)
mdhol
tued o dyine how an obied
whn SkC)
ib vepelrld as aAbing
Print () is callod
clas pevhon :
def -rinit (Sel, name):
name 2 Mane

s - (se):
yean t se. name
p evsn ('Alice") medhod.
pint (P) # Wses

trngdaMethod:
- (en C) '.
Csel)
do d e te behaui or
) This me fhod is cucd kam called
oha (enc) tun chon
Object.
alas Box:
def --init ~-( sey , im):
sell. items itmy.
Csell)
(sly. idomy)
b- Box( C,2, s;4)
pint (len Cb)) # wses
--len-- neBod

You might also like