Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 37
    Good answer. I'd just like to point out that in C++11, rather than making the assignment operator and copy constructor private, you can remove them completely like this: Foo(const Foo&) = delete; // no copy constructor and Foo& Foo=(const Foo&) = delete; // no assignment operator Commented Jun 5, 2013 at 10:19
  • 14
    "However, C++ inherited its default assignment and copy constructors from C" That does not imply why you have to make ALL C++ types this way. They should have just restricted this to plain old PODs, just the types that are in C already, no more. Commented Aug 11, 2014 at 11:25
  • 8
    I can certainly understand why C++ inherited these behaviors for struct, but I do wish that it let class behave differently (and sanely). In the process, it also would have given a more meaningful difference between struct and class beside default access. Commented Jun 1, 2018 at 0:42