Top "Copy-constructor" questions

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

Why is the copy constructor called when we pass an object as an argument by value to a method?

Why is the copy constructor called when I pass an object as an argument by value to a function? Please …

c++ copy-constructor pass-by-value
assignment operator vs. copy constructor C++

I have the following code to test out my understanding of basic pointers in C++: // Integer.cpp #include "Integer.h" …

c++ pointers memory-management copy-constructor
Strange "Member function not viable" error in templated linear algebra vector class

I'm implementing a templated vector class (not the data container, but the vector in the linear algebra sense), and I'm …

c++ vector operator-overloading copy-constructor deep-copy
Is it possible to define an std::thread and initialize it later?

My aim is to keep an std::thread object as data member, and initialize it when needed. I'm not able …

c++ copy-constructor stdthread
Check for "self-assignment" in copy constructor?

Today in university I was recommended by a professor that I'd check for (this != &copy) in the copy constructor, …

c++ class copy-constructor
Copy constructor initialization lists

I know that if you leave a member out of an initialization list in a no-arg constructor, the default constructor …

c++ copy-constructor
Derived and base class, can I set the base explicitly?

public class SuperCar: Car { public bool SuperWheels { get {return true; } } } public class Car { public bool HasSteeringWheel { get {return true;} } } How …

c# reflection copy-constructor derived-class
Calling assignment operator in copy constructor

Are there some drawbacks of such implementation of copy-constructor? Foo::Foo(const Foo& i_foo) { *this = i_foo; } As …

c++ copy-constructor
std::thread pass by reference calls copy constructor

Well I have an issue with passing data into a thread using std::thread. I thought I understood the general …

c++ multithreading c++11 copy-constructor stdthread
Why user-defined move-constructor disables the implicit copy-constructor?

While I'm reading boost/shared_ptr.hpp, i saw this code: // generated copy constructor, destructor are fine... #if defined( BOOST_…

c++ boost c++11 copy-constructor rvalue-reference