Sunday 4 August 2013

Multiple Inheritance(2)

#include<iostream.h>
#include<conio.h>
class mahi
{
    public:
        int m;
        void getm(int);
};
class joshi
{
    public:
        int j;
        void getj(int);
};
class mj:public mahi,public joshi
{
    public:
        void display(void);
};
void mahi::getm(int h)
{
    m=h;
}
void joshi::getj(int v)
{
    j=v;
}
void mj::display()
{
    cout<<"\n M= "<<m;
    cout<<"\n J= "<<j;
    cout<<"\n M*J= "<<m*j;
};
void main()
{
    clrscr();
    mj m1;
    m1.getm(10);
    m1.getj(5);
    m1.display();
    getch();
}

Here Is The Output :)


No comments:

Post a Comment