gogoWebsite

The difference between new instantiation and no brackets

Updated to 2 days ago

In parentheses call constructors without parameters, and in parentheses call default constructors or unique constructors.

The rule of initialization in C++ when new may be: for classes with constructors, whether they have or not, they are initialized with constructors; if there is no constructor, the new without brackets only allocates memory space and does not initialize memory, and the new with brackets will be initialized to 0 while allocating memory.