Multiple inheritance is when a child class inherits traits from more than one parent class - Inheritance

Q.  When a child class inherits traits from more than one parent class, this type of inheritance is called _______________ inheritance.
- Published on 17 Jul 15

a. Hierarchical
b. Hybrid
c. Multilevel
d. Multiple

ANSWER: Multiple
 

    Discussion

  • Brijesh   -Posted on 08 Oct 15
    When a child class inherits traits from more than one parent class, this type of inheritance is called multiple inheritance.
    Example:
    class A
    {
    public:
    void Amethod() { cout << "A's method called" << endl; }
    };

    class B
    {
    public:
    void Bmethod() { cout << "B's method called" << endl; }
    };

    class C: public B, public A
    {
    public:
    void Cmethod() { cout << "C's method called" << endl; }
    };

    int main()
    {
    C obj;
    obj.Amethod();
    obj.Bmethod();
    obj.Cmethod();
    return 0;
    }

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)