☰
  • 首页
  • 规则分类
  • 项目介绍
search
•••

参数名称在声明处和实现处应保持一致

8.3 ID_inconsistentParamName
目录 › next › previous

参数名称在声明处和实现处不一致会误导函数的使用者,而且很可能是实现错误。

示例:

int foo(int a, int b);    // Declaration

int foo(int b, int a) {   // Non-compliant, which is which??
    return a > b? 1: -1;
}

例中参数 a 和 b 在声明处和实现处的顺序是颠倒的,令人非常困惑。

相关

ID_inconsistentDeclaration

参考

MISRA C++ 2008 8-4-2
Copyright©2024 360 Security Technology Inc., Licensed under the Apache-2.0 license.