Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<conio.h>
- #include<iostream>
- using namespace std;
- class Base1
- {
- protected :int a;
- public :void geta();
- };
- class Base2
- {
- protected :int b;
- public :void getb();
- };
- class Derive :public Base1,public Base2
- {
- private :int c;
- public :void getc();
- void display();
- };
- void Base1 ::geta()
- {
- cout<<"Enter value for A:";
- cin>>a;
- }
- void Base2 ::getb()
- {
- cout<<"Enter value for B:";
- cin>>b;
- }
- void Derive ::getc()
- {
- cout<<"Enter value for C:";
- cin>>c;
- }
- void Derive ::display()
- {
- cout<<"A = "<<a<<endl;
- cout<<"B = "<<b<<endl;
- cout<<"C = "<<c<<endl;
- }
- int main()
- {
- Derive obj;
- obj.geta();
- obj.getb();
- obj.getc();
- obj.display();
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment