https://stackoverflow.com/questions/71380971/why-is-new-int-10-wrong
https://en.cppreference.com/w/cpp/language/new
Doesn't work:
Ok:
Reasoning:
auto p = new int (*)[10]; // error: parsed as (new int) (*[10]) ()
typedef int array[10];
auto p = new array *;
Ok:new (int (*[10])()); // okay: allocates an array of 10 pointers to functions
Syntax for new without initializer is either
or
new (type)
new type
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.