ECE244H1 Chapter 15: ECE244 Ch15 Inheritance
DepartmentElectrical and Computer Engineering
This preview shows page 1. to view the full 4 pages of the document.
ECE244 Chapter 15 Inheritance
- Process by which a new class is created from another class
- Allows programmers to enhance existing class without modifying code of these class
- Purpose: facilitate code reuse
- Has all the variables and functions as base class
- Also has additional member functions and member variables
class <derived_class_name> : public <base_class_name>
Names for these classes:
- Parent Class → Base Class
- Child Class → Derived Class
- Ancestor Class → Parent of a Parent of a Parent of another class
What if derived class and base class both define the same function?
- Redefine the function
- Override the function
What does derived class inherit?
- All public and private data members of base class
- All public and private function members of base class
- Private data and function members are not accessible in derived class
You're Reading a Preview
Unlock to view full version