2

What is the difference between the following initializations?

  1. new MyClass()
  2. MyClass()

From my understanding the first one allocates the memory on heap and returns a pointer whereas in the second case a reference to the object is returned but the object resides on stack. In both cases the default constructor is called. Please correct me if I am wrong.

ibp73
  • 632
  • 6
  • 14

0 Answers0