Is there a way by which we can prevent compilers from defining copy constructors, operator = overload for C++ classes.
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
Defining? Well, yes. They are always declared (explicitly by you or implicitly by the compiler), but they are only defined by the compiler when/if you actually use them. Don't use them - and the compiler will not define them.
Of course, if by "prevent compilers from defining ...", you mean "prevent compilers from successfully defining...", i.e. if you want to make the implicit definition attempt fail at compile time, then you can achieve that by adding non-copy constructible and/or non-assignable subobject to your class (like a base or member with private copy-constructor and private assignment operator, for example).