Textbook Notes (280,000)
CA (170,000)
UTSG (10,000)
ECE (80)
Chapter 15

ECE244H1 Chapter 15: ECE244 Ch15 Inheritance


Department
Electrical and Computer Engineering
Course Code
ECE244H1
Professor
Tarek Abdelrahman
Chapter
15

This preview shows page 1. to view the full 4 pages of the document.
ECE244 Chapter 15 Inheritance
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
Derived Class
- Has all the variables and functions as base class
- Also has additional member functions and member variables
- Header:
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
Base Class
(Parent
Derived
Class
Create
You're Reading a Preview

Unlock to view full version