Sunday, January 1, 2012

Show the use of constructor in 'C++'

Example



#include<iostream.h>
#include<conio.h>
class demo
{
int x;
public:
demo()
{
}


demo(int d,int b=5)
{

cout<<"ADDITION OF TWO NUMBER IS::"<<b+d;

}

};

int main()
{
int p,q;
clrscr();
demo d(3);
getch();
return 0;
}
/*=============================================================
OUTPUT
ADDITION OF TWO NUMBER IS::8
*/

No comments:

Post a Comment