Advertisement



< Prev
Next >



Python - Inheritance





Like most of the programming languages, Python language also gives us a powerful OOP feature known as inheritance. Inheritance allows us to create a class by inheriting the features of an existing class. The class that wants to use the features of another class is referred to as the subclass or derived class, whereas the class whose features are to be inherited by another class is referred to as the base class. Hence, inheritance gives Python the power of reusability.




What features a subclass inherits from its base class, through inheritance?



Note - Unlike other programming languages like C++ and Java, Python does not have visibility modes like private/public/protected, hence all the members declared in a class are inherited by its subclass through inheritance.




Syntax of Inheritance


Let us take a look at a general syntax of performing inheritance, using which we could define a derived class which is inheriting a base class.


class derived-class-name(base-class-name):
	#member1 of derived class
	#member2 of dervied class
	.
	.
	.






Types of Inheritance






Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




Advertisement

Notifications



Please check our latest addition

PYTHON


Advertisement