overloading in python?

Опубликовано: 11 Сентябрь 2024
на канале: Rahul Gaikwad
12
0

💥Overloading
We can use the same operator or methods for different purposes.

There are 3 types of Overloading
1. Operator Overloading
2. Method Overloading
3. Constructor Overloading



💥Operator Overloading:

We can use the same operator for multiple purposes, which is nothing but operator
overloading.
Python supports operator overloading.

Example:
💥+ operator can be used for Arithmetic addition and String concatenation
print(10+40) # 50
print('Rahul'+'Patil') #RahulPatil

💥* operator can be used for multiplication and string repetition purposes.
print(10*2) #20
print('rahul'*3) # rahulrahulrahul

💥Method Overloading:
If two methods having same name but different type of arguments then those methods
are said to be overloaded methods.


But in Python Method overloading is not possible.
If we are trying to declare multiple methods with same name and different number of
arguments then Python will always consider only the last method.

🔥How we can handle Overloaded Method Requirements in Python:
Most of the times, if method with variable number of arguments required then we can
handle with default arguments or with a variable number of argument methods.

💥Constructor Overloading:
Constructor overloading is not possible in Python.
If we define multiple constructors then the last constructor will be considered.

#python3
#coding #objectorientedprogramming #oopsconcept #programmingconcepts


На этой странице сайта вы можете посмотреть видео онлайн overloading in python? длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Rahul Gaikwad 11 Сентябрь 2024, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 12 раз и оно понравилось 0 зрителям. Приятного просмотра!