Possible Duplicate:
Do the parentheses after the type name make a difference with new?
Hello all,
/* Sorry for my original post and I correct my question as follows */
Assume that ClassA is a well-defined C++ class and has a default constructor, etc. What is the difference between the following two cases:
ClassA* pClassA = new ClassA; // case I
classA* pClassA = new ClassA(); // case II
It has been considered as a good practice to use case I if possible.
What is the reason for this?
Because in case I only default constructor of ClassA will be called, while in case II, a temporary instance of ClassA will be constructed.
Is that correct?
Thank you