C ++ class initialization with and without parentheses

What is the difference between the next two initializations?

class Pod { public: int a, b; }; Pod *p1 = new Pod; Pod *p2 = new Pod(); 
+6
source share
1 answer

In the first case, the object remains uninitialized, while in the second case, the object is guaranteed to be initialized with a value, which in this case, since the type is POD, means zero-initialized

+8
source

All Articles