Tuesday, 2 July 2013

PROGRAM TO IMPLEMENT MULTIPLE INHERITENCE

//PROGRAM TO IMPLEMENT MULTIPLE INHERITENCE
/*MADE BY KRISHNA AGARWAL*/
#include<iostream.h>
#include<conio.h>
class M
{
    protected:
    int m;
    public:
    void get_m();
};
void M::get_m()
{
    cout<<"enter the value of m\n";
    cin>>m;
}
class N
{
    protected:
    int n;
    public:
    void get_n();
};
void N::get_n()
{
    cout<<"enter the value of n\n";
    cin>>n;
}
class P:public M, public N
{
    public:
    void display();
};
void P::display(void)
{
    cout<<"\nthe value of m is = "<<m;
    cout<<"\nthe value of n is = "<<n;
    cout<<"\nthe value of product is = "<<m*n;
}
void main()
{
    clrscr();
    P p;
    p.get_m();
    p.get_n();
    p.display();
    getch();
}

No comments:

Post a Comment