What is a Copy Constructor in C++?

Copy constructor is used to copy the data of one object which already exists to the new object that is the reason why it is known as copy constructor.
E.g.:
class counter
{
int count;
Public:
counter(int c)
{
count=c;
}
counter(counter &ob) //Copy constructor
{
cout<<”Constructor called”. count=ob.count; } void show() { cout<<”\n count=”<

More Questions

Leave a Reply

Word Verfication * Time limit is exhausted. Please reload CAPTCHA.