Tuesday, October 14, 2008

7.2 PROGRAM TO IMPLEMENT COPY CONSTRUCTORS

#include
#include

class abc
{
int x,y,z;
public:
abc()
{
x=10;
y=20;
}
abc(int a,int b)
{
x=a;
y=b;
}
abc(abc &o)
{
x=o.x;
y=o.y;
}
void display()
{
cout<<"the result of is "< }
};

void main()
{
clrscr();
abc o1,o2(5,10),o3(o2);
o1.display();
o2.display();
cout<<"using copy constructors\n";
o3.display();
getch();
}






OUTPUT :

the result of is 30
the result of is 15
using copy constructors
the result of is 15

No comments: