/*PROGRAM TO IMPLEMENT COPY CONSTRUCTOR*/
#include"iostream.h"
class code
{
int id;
public:
code(){}
code(int a){id=a;}
code(code &x)
{
id=x.id;
}
void display(void)
{
cout<<id;
}
};
int main()
{
code A(150);
code B(A);
code C=A;
code D;
D=A;
cout<<"\n id of A: ";A.display();
cout<<"\n id of B: ";B.display();
cout<<"\n id of C: ";C.display();
cout<<"\n id of D: ";D.display();
return 0;
}
Output :
id of A: 150
id of B: 150
id of C: 150
id of D: 150


 
 8:25 PM
8:25 PM
 Anonymous
Anonymous
 
 Posted in:
 Posted in:   










 
 
0 comments:
Post a Comment