About 50 results
Open links in new tab
  1. What is a copy constructor in C++? - Stack Overflow

    Jan 30, 2010 · A constructor is the copy constructor if its first parameter is a reference to the class type and any additional parameters have default values.

  2. When do we have to write a user-defined copy constructor?

    Jul 19, 2010 · I know that C++ compiler creates a copy constructor for a class. In which case do we have to write a user-defined copy constructor? Can you give some examples?

  3. Copy constructor for a class with unique_ptr - Stack Overflow

    Apr 16, 2013 · How do I implement a copy constructor for a class that has a unique_ptr member variable? I am only considering C++11.

  4. The copy constructor and assignment operator - Stack Overflow

    Mar 20, 2011 · No, they are different operators. The copy constructor is for creating a new object. It copies an existing object to a newly constructed object.The copy constructor is used to initialize a …

  5. Creating a copy constructor for a linked list - Stack Overflow

    This is homework I'm working on implementing a linked list class for my C++ class, and the copy constructor has be very confusing for me. The linked list is comprised of structs called Elems: st...

  6. c++ - Const Class Member Copy Constructor - Stack Overflow

    Apr 2, 2016 · 5 operator= is not the copy-constructor, it is the assignment operator. const objects cannot be updated, so in your assignment operator you cannot modify the object. If you don't declare your …

  7. c++ - Copy constructor with pointers - Stack Overflow

    A copy constructor does a copy; the semantics of whether it is a "deep" or "shallow" copy is up to the implementer. A pointer data-member does not necessitate or require a custom copy-constructor, and …

  8. What is the difference between the copy constructor and move ...

    So, the only difference between a copy constructor and a move constructor is whether the source object that is passed to the constructor will have its member fields copied or moved into the new object. I …

  9. What's the difference between assignment operator and copy …

    Copy constructor is called when a new object is created from an existing object, as a copy of the existing object. And assignment operator is called when an already initialized object is assigned a new value …

  10. Why C++ copy constructor must use const object?

    Copy constructors should not modify the object it is copying from which is why the const is preferred on the other parameter. Both will work, but the const is preferred because it clearly states that the object …