Python - Operator Overloading

Pubblicato il: 18 maggio 2023
sul canale di: 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


In questa pagina del sito puoi guardare il video online Python - Operator Overloading della durata di ore minuti seconda in buona qualità , che l'utente ha caricato PythonMaestro 18 maggio 2023, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 6 volte e gli è piaciuto 2 spettatori. Buona visione!