Why put void in params?

前端 未结 6 1032
别跟我提以往
别跟我提以往 2020-12-08 19:33

What\'s the reason for putting void inside of the params?

Why not just leave it blank?

void createLevel(void);

void createLevel();
6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 20:03

    void in function argument lists is a relict of the past (C). In C++, you should leave the parentheses empty. Of course you can keep the void if it makes you happy.

    In C, if you declare a function with empty parentheses, the meaning is that the number of parameters is unknown. void can be used to make it explicit that no parameters are expected.

提交回复
热议问题