Computer Science, asked by yugantar4857, 1 year ago

What is copy constructor ?

Answers

Answered by tripti998
0

hey mate

Hera is yr ans

In the C++ programming language, a copy constructor is a special constructor for creating a new object as a copy of an existing object. Copy constructors are the standard way of copying objects in C++, as opposed to cloning, and have C++-specific nuances.

The first argument of such a constructor is a reference to an object of the same type as is being constructed (const or non-const), which might be followed by parameters of any type (all having default values).

Normally the compiler automatically creates a copy constructor for each class (known as an implicit copy constructor) but for special cases the programmer creates the copy constructor, known as a user-defined copy constructor. In such cases, the compiler does not create one. Hence, there is always one copy constructor that is either defined by the user or by the system.

A user-defined copy constructor is generally needed when an object owns pointers or non-shareable references, such as to a file, in which case a destructor and an assignment operator should also be written (see Rule of three).


vibhamalviya8: this answer was copied by google
tripti998: noooo
vibhamalviya8: yes
Danish3480: hi
tripti998: maje ma
tripti998: chrome sa
Danish3480: what
tripti998: google nhi chrome sa
Danish3480: oh
Danish3480: is you in your dp
Answered by vibhamalviya8
1
The copy constructor is the constructor which creats an object by initializing it with an object of the same class , which has been create previously..........

mark me brainliest
Similar questions