Do built-in types have default constructors?

Simple Answer: Technically No.

Long Answer:

No. But!

The syntax you use to initialize them makes them look like they are being constructed by a default constructor or a default copy constructor.

int x0(5);     // Looks like a constructor. Behaves like one: x is initialized.
int x1{5};

int y0();      // Fail. Actually a function declaration.
// BUT
int y1{};      // So new syntax to allow for zero initialization
int z0 = int();// Looks like a constructor. Behaves like a constructor (0 init).
int z1 = int{};

int a0(b);     // Again.
int a1{b};

So technically there are no constructors for basic-POD types. But for all intents and purposes they act just like they have a copy constructor and default constructor (when initialized with the braces).

If it looks like a duck and quacks like a duck, then its very duck like.

Leave a Comment