C++ Programming Code Examples C++ > Beginners Lab Assignments Code Examples Inheritance allows the child class to acquire the properties Inheritance allows the child class to acquire the properties Inheritance is one of the feature of Object Oriented Programming System(OOPs), it allows the child class to acquire the properties (the data members) and functionality (the member functions) of parent class. What is child class? A class that inherits another class is known as child class, it is also known as derived class or subclass. What is parent class? The class that is being inherited by other class is known as parent class, super class or base class. #include <iostream> using namespace std; class Teacher { public: Teacher(){ cout<<"Hey Guys, I am a teacher"<<endl; } string collegeName = "Happy College :)"; }; //This class inherits Teacher class class MathTeacher: public Teacher { public: MathTeacher(){ cout<<"I am a Math Teacher"<<endl; } string mainSub = "Math"; string name = "Jack"; }; int main() { MathTeacher obj; cout<<"Name: "<<obj.name<<endl; cout<<"College Name: "<<obj.collegeName<<endl; cout<<"Main Subject: "<<obj.mainSub<<endl; return 0; }