In this program we will simply inherit two classes and clear the concept of inheritance of two classes.
The code is given below.
//Code Starts
#include<iostream>
#include<conio.h>
using namespace std;
class woman{
public:
void eat()
{
cout<<"Woman Eat Function"<<endl;
}
};
class fish{
public:
void swim()
{
cout<<"Fish Swim Function ";
}
};
class mermaid:public woman, public fish{
};
int main()
{
mermaid m1;
m1.eat();
m1.swim();
getch();
}
//Code ends
OUTPUT:

The code is given below.
//Code Starts
#include<iostream>
#include<conio.h>
using namespace std;
class woman{
public:
void eat()
{
cout<<"Woman Eat Function"<<endl;
}
};
class fish{
public:
void swim()
{
cout<<"Fish Swim Function ";
}
};
class mermaid:public woman, public fish{
};
int main()
{
mermaid m1;
m1.eat();
m1.swim();
getch();
}
//Code ends
OUTPUT:
0 comments:
Post a Comment