Wednesday, November 15, 2023

multiple inheritance

 

#include<iostream.h>

#include<conio.h>

class A

{

private:

int x;

public:

void getA()

{

cout<<"Enter x : ";

cin>>x;

}

void showA()

{

cout<<"X = "<<x<<endl;

}

};

class B

{

private:

int y;

public:

void getB()

{

cout<<"Enter y: ";

cin>>y;

}

void showB()

{

cout<<"Y = "<<y<<endl;

}

};

class C : public A, public B

{

public:

void getC()

{

getA();

getB();

}

void showC()

{

showA();

showB();

}

};

void main()

{

clrscr();

C obj;

obj.getC();

obj.showC();

getch();

}

0 comments:

Post a Comment

Data Structures with C++



NET/SET/CS PG



Operating Systems



Computer Networks



JAVA



Design and Analysis of Algorithms



Programming in C++

Top