Friday, 10 April 2020

Program: Write a Program using copy constructor to copy data of an object to another object.

#include<iostream.h>
#include<conio.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(100); 
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;

No comments:

Post a Comment