Using void in functions without parameter?

前端 未结 5 984
说谎
说谎 2021-02-19 07:44

In C++ using void in a function with no parameter, for example:

class WinMessage
{
public:
    BOOL Translate(void);
};

is redunda

5条回答
  •  一个人的身影
    2021-02-19 08:35

    I feel like no. Reasons:

    • A lot more code out there has the BOOL Translate() form, so others reading your code will be more comfortable and productive with it.
    • Having less on the screen (especially something redundant like this) means less thinking for somebody reading your code.
    • Sometimes people, who didn't program in C in 1988, ask "What does foo(void) mean?"

提交回复
热议问题