This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//COPY CONSTRUCTOR | |
#include<iostream> | |
#include<conio.h> | |
using namespace std; | |
class rectangle | |
{ | |
int length; | |
public: | |
rectangle(int c) | |
{ | |
length=c; | |
} | |
rectangle(rectangle &ob)//copy constructor | |
{ | |
length=ob.length; | |
} | |
void show() | |
{ | |
cout<<"\nlength\t"<<length; | |
} | |
}; | |
int main() | |
{ | |
rectangle r1(4); | |
rectangle r2(r1); | |
r1.show(); | |
r2.show(); | |
getch(); | |
return 0; | |
} |
Comments
Post a Comment
Thanks for the comment and don't forget to subscribe.