|
|
cire wrote: |
---|
"This will disable the automatic generation of a copy assignment operator and default constructor, of course." |
No, it won't |
|
|
Error 1 error C2512: 'Dog' : no appropriate default constructor available Error 2 error C2582: 'operator =' function is unavailable in 'Dog' |
In your code, it won't generate them because of the initialisation rules of references |
... A defaulted default constructor for class X is defined as deleted if: — X is a union-like class that has a variant member with a non-trivial default constructor, — any non-static data member with no brace-or-equal-initializer is of reference type, — any non-variant non-static data member of const-qualified type (or array thereof) with no brace-orequal- initializer does not have a user-provided default constructor, — X is a union and all of its variant members are of const-qualified type (or array thereof), — X is a non-union class and all members of any anonymous union member are of const-qualified type (or array thereof), — any direct or virtual base class, or non-static data member with no brace-or-equal-initializer, has class type M (or array thereof) and either M has no default constructor or overload resolution (13.3) as applied to M’s default constructor results in an ambiguity or in a function that is deleted or inaccessible from the defaulted default constructor, or — any direct or virtual base class or non-static data member has a type with a destructor that is deleted or inaccessible from the defaulted default constructor. |
Explicitly-defaulted functions and implicitly-declared functions are collectively called defaulted functions, and the implementation shall provide implicit definitions for them (12.1 12.4, 12.8), which might mean defining them as deleted. |