Do the parentheses after the type name make a difference with new?

后端 未结 6 1290
余生分开走
余生分开走 2020-11-21 04:15

If \'Test\' is an ordinary class, is there any difference between:

Test* test = new Test;

and

Test* test = new Test();
         


        
6条回答
  •  半阙折子戏
    2020-11-21 05:18

    Assuming that Test is a class with a defined constructor, there's no difference. The latter form makes it a little clearer that Test's constructor is running, but that's about it.

提交回复
热议问题