C++ Language/Objects/Constructors/KeepingDefaultConstructor

From Wikibooks, open books for an open world
Jump to navigation Jump to search

The compiler provides a do-nothing implementation of the "default constructor" (one that has no parameters), if the programmer hasn't manually provided a custom implementation for it. But traditionally, if the programmer writes any other constructor (having some other overloaded signature of parameters), then this built-in default constructor was not provided by the compiler.

If you do write some other constructor, but you still also want the compiler to provide its built-in default constructor, request it with CRType() = default;.

Additional information about keeping the default constructor