1

Possible Duplicate:
Difference between A* pA = new A; and A* pA = new A();
Variable initialization (pointer and value)

Assuming that MyClass has a default constructor, what's the difference between

MyClass *mc = new MyClass;

and

MyClass *mc = new MyClass();
Community
  • 1
  • 1
Alan
  • 469
  • 10
  • 26

1 Answers1

6

Assuming that MyClass has a default constructor

2 extra characters in the code.

If the class is a POD type (not your case), the latter will perform value-initialization.

Luchian Grigore
  • 253,575
  • 64
  • 457
  • 625