What is a base class?

What is a base class?

- Inheritance is one of the important features of OOP which allows us to make hierarchical classifications of classes. In this, we can create a general class which defines the most common features. Other more specific classes can inherit this class to define those features that are unique to them. In this case, the class from which other classes are inherited is referred as base class.
- For example, a general class vehicle can be inherited by more specific classes car and bike. The class vehicle is base class in this case.
class Base
{
   int a;
   public:
       Base()
       {
          a = 1;
          cout <<”inside Base class”;
       }
};

class Derived:: public Base //class Derived is inheriting class Base publically
{
   int b;
   public:
       Derived()
       {
          b = 1;
          cout <<”inside Derived class”;
       }
};
What is private inheritance? - C++
What is private inheritance? - When a class is being derived from another class, we can make use of access specifiers....
What is protected inheritance? - C++
What is protected inheritance? - When a class is being derived from another class, we can make use of access specifiers...
How do we implement inheritance in C++?
How do we implement inheritance in C++? - The inheritance feature in C++ is implemented in the following manner....
Post your comment
Discussion Board
Comments
Your site is very good and it is very easy to understand topics.
Thank you
Samba 01-10-2013