In header:
class ChangeSignature
{
public:
int Method3(int a, int b);
};
In cpp:
int ChangeSignature::Method3(int a, int b)
{
return a + b;
}
static void TestMethods()
{
ChangeSignature c;
int (ChangeSignature::*result)(int, int) = &ChangeSignature::Method3;
int const sum = (c.*result)(3, 4);
assert(sum == 7);
}
Change Signature on Method3 to
int Method3(const int& a, int b);
Then the signature of the pointer-to-method variable result is not changed, leading to invalid code.