Python - Operator Overloading

Publié le: 18 mai 2023
sur la chaîne: PythonMaestro
6
2

In this video, we will learn how we can use operators such plus (+), minus (-), equality (==) etc. on our custom class objects.

Operator overloading in object oriented programming is way to change operator behaviour based on operands.

For example: plus (+) operator concatenate two operands if the data type of operand is string, but when operator data type interger/float it perform add operation (i.e. add those numbers)

value1 = 'Arnab'
value2 = 'Ayan'
operation: value1 + value2 will return result 'ArnabAyan'

but if values are numbers
value1 = 10
value2 = 50
operation: value1 + value2 will return result 60

#python #pythontutorial #oops


Sur cette page du site, vous pouvez voir la vidéo en ligne Python - Operator Overloading durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur PythonMaestro 18 mai 2023, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 6 fois et il a aimé 2 téléspectateurs. Bon visionnage!