Top "Copy-constructor" questions

A copy constructor is a constructor that creates a new object that is a clone of an existing object.

What is the copy-and-swap idiom?

What is this idiom and when should it be used? Which problems does it solve? Does the idiom change when …

c++ copy-constructor assignment-operator c++-faq copy-and-swap
What is The Rule of Three?

What does copying an object mean? What are the copy constructor and the copy assignment operator? When do I need …

c++ copy-constructor assignment-operator c++-faq rule-of-three
Clone() vs Copy constructor- which is recommended in java

clone method vs copy constructor in java. which one is correct solution. where to use each case?

java clone copy-constructor
Dynamically allocating an array of objects

I have a class that contains a dynamically allocated array, say class A { int* myArray; A() { myArray = 0; } A(int size) { …

c++ memory-management pointers destructor copy-constructor
Disable copy constructor

I have a class : class SymbolIndexer { protected: SymbolIndexer ( ) { } public: static inline SymbolIndexer & GetUniqueInstance ( ) { static SymbolIndexer uniqueinstance_ ; return uniqueinstance_ ; } }; How …

c++ copy-constructor
C++ Compiler Error C2280 "attempting to reference a deleted function" in Visual Studio 2013 and 2015

This snippet is compiled without errors in Visual Studio 2013 (Version 12.0.31101.00 Update 4) class A { public: A(){} A(A &&){} }; int …

c++ visual-c++ copy-constructor c++14
Copy constructor and = operator overload in C++: is a common function possible?

Since a copy constructor MyClass(const MyClass&); and an = operator overload MyClass& operator = (const MyClass&); have pretty …

c++ variable-assignment copy-constructor c++-faq
default copy constructor

Can the (implicit)default copy constructor be called for a class that has already user-defined constructor but that is not …

c++ constructor copy default copy-constructor
Copy constructor with pointers

I have recently discovered that when I have pointers within a class, I need to specify a Copy constructor. To …

c++ pointers copy-constructor
When do we have to use copy constructors?

I know that C++ compiler creates a copy constructor for a class. In which case do we have to write …

c++ copy-constructor