Sunday 4 August 2013

Inheritance Example(3)

#include<iostream.h>
#include<conio.h>
class mahi
{
    public:
        int a,b;
    void putdata()
    {
        cout<<"\n Enter The Value of A= ";
        cin>>a;
        cout<<"\n Enter The Value of B= ";
        cin>>b;
    }
    int set(void);
    int show(void);
};
class pal:public mahi
{
    public:
        int mul(int,int);
        int div(int,int);
        int display(void);
};
int mahi::set()
{
    return a;
    return b;
}
int mahi::show()
{
    cout<<"\n A= "<<a;
    cout<<"\n B= "<<b;
}
int pal::mul(int x,int y)
{
    a=x;
    b=y;
}
int pal::div(int x,int y)
{
    a=x;
    b=y;
}
int pal::display()
{
    cout<<"\n A=X= "<<a;
    cout<<"\n B=Y= "<<b;
    cout<<"\n A*b= "<<a*b;
    cout<<"\n A/b= "<<a/b;
}
void main()
{
    clrscr();
    pal p;
    p.putdata();
    p.show();
    p.display();
    getch();
}

Here is the Output :)


No comments:

Post a Comment