Please enable JavaScript.
Coggle requires JavaScript to display documents.
Topic 5: generic, Inheritance, & Polymorphism - Coggle Diagram
Topic 5: generic, Inheritance, & Polymorphism
-
Inheritance
What is inheritance?
provides a way to create a new class from an existing class. The new class is a specialized version of the existing class.
Classes organised into a ‘classification hierarchy’.
Classes can inherit attributes and methods from other classes, and add extra attributes and methods of its own.
-
Terminology
Base class or parent class or super class – A class from which another class inherits.
The base class represents general characteristics shared by the derived classes.
Derived class or child class or subclass – A class which inherits some of its attributes and methods from another class.
-
What Does a Child Have?
An object of the derived class has all members defined in child class all members declared in parent class
Class Access Specifiers
Member accessibility can be specified at two area Inside each class. (called Class Access Specifier) When a derived class extends the base class (called Inheritance Specifier).
-
Multiple Inheritance
A derived (child) class can have more than one base (parent) class.
Each base class can have its own access specification in derived class's definition
Multiple inheritance allows a derived class to inherit features from different classes.
-