This is how you can inherit a class in C++
The class in which you have to inherit is known as derived class and the class from which you want to inherit is known as base class.
Syntax:
class <derived-class name> : public/private/protected <base-class name>
Example:
class dog : public animal
Why I used a access specifier before the base class?
Before writing any class, you use to write private, public or private access specifier to show the access nature of the program, so if you write public before base class, the class animal elements will be defined in class dog as public, if you write protected before the base class, it will be defined under the protected: section of dog class and so on.