CodeClerks

Multiple Inheritance in C++



Enter a reason for deleting this comment

Multiple Inheritance in C++

A class can inherit the attributes of two or more classes. This is known as multiple inheritance. Multiple Inheritance allows us to combine the features of several existing classes as a starting point for defining new classes. It is like a child inheriting the physical features of one parent and the intelligence of another. Lets see an example program of multiple inheritance in C++....

#include

using namespace std;

class alpha

{

protected:

    int m;

public :

    void get_m(int);

};

class beta

{

protected:

    int n;

public:

    void get_n(int);

};

class gama : public alpha, public beta

{

public:

    void display(void);

};

void alpha :: get_m(int x)

{

    m = x;

}

void beta :: get_n(int y)

{

    n = y;

}

void gama :: display(void)

{

    cout

Comments

Please login or sign up to leave a comment

Join