#include<iostream.h>
#include<conio.h>
class Base
{
public:
int a;
};
class D1:virtual public Base
{
public:
int b;
void input()
{
cout<<"Enter value of b(D1)";
cin>>b;
}
};
class D2:virtual public Base
{
public:
int c;
void read()
{
cout<<"Enter value of c(D2)";
cin>>c;
}
};
class D3:public D1,public D2
{
public:
int total;
void enter()
{
cout<<"Enter value of a(Base)";
cin>>a;
input();
read();
}
void sum()
{
total=a+b+c;
cout<<"Sum of Three numbers"<<total;
}
};
void main()
{
D3 ob;
ob.enter();
ob.sum();
getch();
}
#include<conio.h>
class Base
{
public:
int a;
};
class D1:virtual public Base
{
public:
int b;
void input()
{
cout<<"Enter value of b(D1)";
cin>>b;
}
};
class D2:virtual public Base
{
public:
int c;
void read()
{
cout<<"Enter value of c(D2)";
cin>>c;
}
};
class D3:public D1,public D2
{
public:
int total;
void enter()
{
cout<<"Enter value of a(Base)";
cin>>a;
input();
read();
}
void sum()
{
total=a+b+c;
cout<<"Sum of Three numbers"<<total;
}
};
void main()
{
D3 ob;
ob.enter();
ob.sum();
getch();
}