Using C++11.
I have a class I want to clean-up a bit by making the following changes:
From
class MyClass {
public:
// code
private:
MyClass(const MyClass&);
MyClass& operator=(const MyClass&);
// members
};
To
class MyClass {
public:
// code
MyClass(const MyClass&) = delete;
MyClass& operator=(const MyClass&) = delete;
private:
// members
};
Knowing that both are declared but not defined, will this change break binary compatibility? Does it improves anything?
If you switch from your first version to the second, where you have accessible, user-declared, deleted constructors, code like this will compile in C++11:
But if you upgrade to C++20, it won't. That might not be something you want. If you stick with your first version, where the constructors are inaccessible, the declaration of
b
won't compile in any language version, so you won't have this problem at least.Here's a demo.