There may be unused formal parameters for a function. This is quite natural in the case of polymorphism, where one of the derived classes may use a parameter which is not at all needed in other derived classes. But you may be forced to pass it (of course, dummy value) in the base class (and in all the derived classes indeed). Now in all the derived classes where the parameter is not at all used, the compiler will pop up with a warning – “unused parameter!!!”.
Although this is harmless, I would avoid the warning in the following way.
void MyClass::MyFunction(bool nonUsedParameter)
{
UNREFERENCED_PARAMETER(nonUsedParameter);
// The code continues
}
A better altenative is to code as follows.
void MyClass::MyFunction(bool /*nonUsedParameter*/)
{
// The code continues
}
Another method is to use the macro UNUSED_ALWAYS, defined in afx.h (Generously informed by Nibu, see comments) instead of UNUSED_PARAMETER.
Posted by cppkid