Why comment parameter names rather than leave it as it is

前端 未结 6 649
隐瞒了意图╮
隐瞒了意图╮ 2021-01-02 10:03

Sometimes I see code like this:

LRESULT OnPaint(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)

Why comment pa

6条回答
  •  离开以前
    2021-01-02 10:31

    If the parameters are really not needed, you don't need to name them

    If you don't name them, at first glance you may not understand why they are there in the first place.

    If you name them, some compilers will you warn you about unused parameters.

    Leaving the names as comments is a middle ground between the two approaches.

提交回复
热议问题