From the course: Nail Your C++ Interview

Unlock the full course today

Join today to access over 23,400 courses taught by industry experts.

Inheritance in C++

Inheritance in C++ - C++ Tutorial

From the course: Nail Your C++ Interview

Inheritance in C++

- [Instructor] Another important feature of object-oriented programming is inheritance. In inheritance, a class can be derived from another class. The derived class is the child class and the parent class is called the base class. Let's look at our example of building a home. You have a home class that has windows, doors, rooms, and more. Suddenly, the word gets out about your wonderful home and your family wants a home just like yours on your street. We know duplicating ourselves is out of the question, but we need to build these homes quickly. If you have a solid home class, then you can create as many different homes as you need, and every single instance will inherit the same features as the original home. Then, you can add features to specific homes, like cousin John needs an extra three bedrooms because his wife is expecting triplets, or sister Sarah wants a pool so she can post selfies by the water all day, and grandma…

Contents