Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //write a program to perform copy constructor with implisit and explisit
- #include<iostream.h>
- #include<conio.h>
- class ombha
- {
- int a,b;
- public:
- ombha() // default constructor code
- {
- a=10;
- b=30;
- }
- ombha (ombha &tmp) // copy constructor code
- {
- a=tmp.a;
- b=tmp.b;
- }
- void display()
- {
- cout<<"A = "<<a<<endl;
- cout<<"B ="<<b<<endl;
- }
- };
- void main ()
- {
- clrscr();
- cout<<"\nDefault Consteructure Called\n";
- ombha o;
- o.display();
- cout<<"\nCopy Consteructor Called With Implisit\n";
- ombha o2; // there are 2 type of copy other constructor 1 one is this
- o2=o;
- o2.display();
- cout<<"\nCopy Consteructor Called With explisit\n";
- ombha o3 = ombha (o); // there are 2 type of copy other constructor 2 one is this
- o3.display();
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement