1

Why does the following program compile?

struct Foo {
    private:
        Foo() = default;
};

int main(int argc, char *argv[])
{
    Foo b{};
    return 0;
}

When the implementation is not defaulted (e.g. Foo() {}) it does not compile. The same happens for g++, clang++ and Visual Studio 2019.

I cannot find anything about this in the documentation, any ideas?

Sergio Losilla
  • 730
  • 1
  • 5
  • 14

0 Answers0