Single inheritance
In single inheritance, we have a single base class and a single derived class. The single derived class inherits the properties of the single base class.
Class “A” is the base class and class “B” is the derived class. The class “B” inherits the properties of the class “A”.
Definition of the derived class
The syntax for defining a base class and derived class
//base class
class base
{
private:
Variables/methods;
protected:
Variables/methods;
public:
Variables/methods;
};//derived class
class derived : private/protected/public base
{
private:
Variables/methods;
protected:
Variables/methods;
public:
Variables/methods;
};
Example:
class base
{
};
class derived:base //by default it is private
{
};