Parenthesis Confusion while creating objects
Parenthesis Confusion while creating objects - C++ Let's see some notations of trying to create objects in different ways of creating objects ClassName obj1; ClassName obj2(); ClassName *obj3 = new ClassName; ClassName *obj4 = new ClassName(); So, which and all the above statements create objects: ClassName obj1 - Yes. Object obj1 is created on stack. ClassName obj2(); - No. C++ compiler will interpret "obj2" as a function definition with no parameters and which returns a ClassName object. ClassName *obj3 = new ClassName; - YES obj3 will be created as a default initialized, which means all POD data types will be left unitialized. ClassName *obj4 = new ClassName(); - YES obj4 will be created as a value initialized, which means all data members will be initialized. Init will be zero-initialized. So, what is a POD class ? POD means "Plain Old Data". In C++, objects are either POD or non-POD. A POD class is said to have data m