Monday, 20 February 2017

Class inheritance in C++

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:

Share:

Related Posts:

0 comments:

Post a Comment