#include <iostream>
class A
{
public:
A() {std::cout << "Default CTOR called; ";}
A(const A& a) = delete;
};
int main()
{
A a1;
// A a2(a1); // This line does not compile because of " = delete' above.
return 0;
}
// Output: Default CTOR called
Reference: https://isocpp.org/wiki/faq/cpp11-language-classes#default-delete
Monday, July 31, 2017
C++11: =delete
Specifying =delete for any of the compiler-generated constructors or assignment operators, makes them unavailable.
Here is an example:
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment