WAP to show the example of multiple inheritances?

#include<iostream>
using namespace std;

class A{
    public:
        int x;
        void getx()
        {
            cout << "enter value of x: ";
            cin >> x;
        }
};

class B{
    public:
        int y;
        void gety()
        {
            cout << "enter value of y: ";
            cin >> y;
        }
};

class C : public A, public B {
    public:
        void sum()
        {
            cout << "Sum = " << x + y;
        }
};

int main()
{
    C obj1;
    obj1.getx();
    obj1.gety();
    obj1.sum();
    return 0;
}
If you found any type of error on the answer then please mention on the comment or report an answer or submit your new answer.
Leave your Answer:

Click here to submit your answer.

s
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments