My C ++ book talks about this (lippman, C ++ primer, 5th ed., P. 508):
A synthesized default constructor is defined as remote if the class ... has a const member whose type does not explicitly define the default constructor and which does not have an initializer in the class. (empirical mine)
Why then does this code cause an error?
class Foo { Foo() { } }; class Bar { private: const Foo foo; }; int main() { Bar f;
The above rule indicates that this should not be an error, because Foo explicitly defines a default constructor. Any ideas?
source share