派生クラスのメンバー変数名が親クラスの 1 つを隠している場合に警告を生成する方法はありますか?
class Mother
{
public:
Mother() : i(0) {}
virtual ~Mother() {}
protected:
int i;
};
class Child : public Mother
{
public:
Child() : Mother(), i(0) {}
virtual ~Child() {}
protected:
int i; /* NOK Expecting warning : declaration of 'int Child::i' shadows 'int Mother::i' */
};
-Wshadow
上記のコードは、g++ でコンパイルした場合、警告を生成しません。