Avoid warning 'Unreferenced Formal Parameter'

前端 未结 7 2402
天命终不由人
天命终不由人 2020-12-04 17:54

I have a super class like this:

class Parent
{
public:
    virtual void Function(int param);
};

void Parent::Function(int param)
{
    std::cout << pa         


        
相关标签:
7条回答
  • 2020-12-04 18:21

    In C++ you don't have to give a parameter that you aren't using a name so you can just do this:

    void Child::Function(int)
    {
        //Do nothing
    }
    

    You may wish to keep the parameter name in the declaration in the header file by way of documentation, though. The empty statement (;) is also unnecessary.

    0 讨论(0)
提交回复
热议问题