Why do we need a copy constructor in C++?

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).

Sizin İçin Seçtik  What is parameterized constructor with example?

Leave a Reply

Your email address will not be published. Required fields are marked *

Why do we need a copy constructor in C++?

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).

Sizin İçin Seçtik  What is a default constructor give one example?

Leave a Reply

Your email address will not be published. Required fields are marked *