Why separate variable definition and initialization in C++?

前端 未结 8 1485
心在旅途
心在旅途 2021-02-18 15:22

I\'m currently working on some quite old C++ code and often find things like

int i;
i = 42;

or

Object* someObject = NULL;
someO         


        
8条回答
  •  执笔经年
    2021-02-18 16:12

    No. It's a matter of style.

    However if he ever wanted to move the declaration out of the function it would be less editing if the declaration and initialization is seperated.

提交回复
热议问题