Wednesday 7 August 2013

Multiple Inheritance(5)

#include<iostream.h>
#include<conio.h>
class a
{
    protected:
        int m;
    public:
        void get1(int);
};
class b
{
    protected:
        int p;
    public:
        void get2(int);
};
class c:public a,public b
{
    public:
        int c;
        void display(void);
};
void a::get1(int x)
{
    m=x;
}
void b::get2(int y)
{
    p=y;
}
void c::display()
{
    c=m+p;
    cout<<"\n Addition= "<<c;
}
void main()
{
    clrscr();
    c c1;
    c1.get1(10);
    c1.get2(10);
    c1.display();
    getch();
}

Here is The Output :)


No comments:

Post a Comment