Sunday, April 12, 2009

CONSTRUCTOR PROGRAM

CONSTRUCTOR

#include
#include
class integer
{
int m,n;
public:
integer(int,int0);
void display()
{
cout<<"m="<< m<<"\n";
cout<<"n="<< n<<"\n";
}
};
integer::integer(int x,int y)
{
m=x;
n=y;
}
void main()
{
clrscr();
integer int1(0,100);
integer int2=integer(25,75);
cout<<"\nobject1\n";
int1.display();
cout<<"\nobject2\n";
int2.display();
getch();
}



Output will be


object1
m=0
n=100

object2
m=25
n=75

No comments:

Post a Comment