情况一、函数的屏蔽:
例如:
void Function(int a,int b)
{
int c = a+b;
}
若是不使用函数Function(int,int), 可以采用#define Function (void)
若是不使用函数Function()(函数没有入参), 可以采用#define Function() 0
情况二、函数参数的屏蔽:
例如:
void Function(int a,int b)
{int c = a ++;
}
在函数Function(a,b)中没有使用参数b时,有部分编译器会告警;
措施:
在定义函数入参时屏蔽函数参数b:void Function(int a,int /* b */ =0 );
在函数内将函数参数b作废:(void) b / static_cast<void>(b);
例程:
#include <iostream>
using namespace std;void test(int a, int b)
{int c = a + b;cout << "test():" << c << endl;
}void test1()
{int cc = 1;cout << "test1():" &