Object initialization with private constructor

58 Views Asked by At

anyone can explain why there is this weird behavior with a private constructor and the uniform initialization:

struct Obj
{
 int a = 0;

private:
  Obj() = default;
};

Obj o; // Error (cannot access private member declared in class 'Obj')
Obj o{10}; // OK <-- Why???

I'm using VC19 with C++17

Thanks G.

0

There are 0 best solutions below