Sunday 4 August 2013

Constructor exp

#include<iostream.h>
#include<conio.h>
class mahi
{
    public:
        int a,b;
    mahi(int,int);
    void show()
    {
        cout<<"\n A+B= "<<a+b;
        cout<<"\n A-B= "<<a-b;
    }
}
mahi::mahi(int x,int y)
{
    a=x;
    b=y;
}
void main()
{
    clrscr();
    mahi m(10,5);
    mahi p(20,10);
    m.show();
    p.show();
    getch();
}

Here is the output :)


No comments:

Post a Comment