saving . . . saved Copy Constructor has been deleted. Copy Constructor has been hidden .
Copy Constructor
Title
Question
What is the main role of Copy Constructor in the concept of constructor and is it save the memory for system?

Advanced-Cpp Constructor-And-Destructor 00-01 min 50-60 sec 10-04-20, 2:40 p.m. Mann_19

Answers:

Dear Mann_19,

A copy constructor is used for creating a new object from an existing one, without explicitly copying each member variables. It is not meant for saving memory, but it is just a matter of neat copying provided by c++.

nags



19-04-20, 11:17 p.m. nags
A copy constructor is a member function which initializes an object using another object of the same class. A copy constructor is called whenever a new variable is created from an object.
03-05-21, 4:41 p.m. saravana_7528

Login to add comment


A copy constructor is a member function which initializes an object using another object of the same class. A copy constructor is called whenever a new variable is created from an object.

A copy constructor has the following general function prototype:

ClassName (const ClassName &old_obj); 

04-05-20, 11:20 p.m. Nityasree


Copy constructor dynamically allocates memory for the copy first and then copies the actual value. In a deep copy, both objects which have to copy and another which has to be copied will be having different memory locations. So, the changes made to one will not affect another. This is used by a user-defined copy constructor.
         A  copy constructor is a member function that initializes an object using another object of the same class.This is the Role of copy constructor..                  
                                                          SACHIN VALAVI  20th  February 2022 
20-02-22, 4:50 p.m. sachinvalavi99@gmail.com


Log-in to answer to this question.