基本クラスにオーバーロードされた関数がある場合、再実装しないすべてのオーバーロードされたコピーに対して基本クラスの名前空間を宣言する必要があるのはなぜですか (少なくとも 1 つを再実装した場合)。たとえば、次のコードを考えてみましょう。
#include <iostream>
class Base {
protected:
int bar;
public:
Base() : bar(0) {}
virtual void Bar(int b) { bar = b; }
virtual int Bar() { return bar; }
};
class Foo : public Base {
protected:
int extraBar;
public:
//virtual void Bar(int b) { extraBar = b; } //Uncomment
};
int main() {
Foo T;
std::cout << T.Base::Bar() << std::endl;
std::cout << T.Bar() << std::endl; //will cause code to not compile
return 0;
}
それを回避する簡単な方法はありますか?数行のコードを手動で変更する必要があります。
func()
func(var)
func(var, var, var)
そして var は決して同じものではないため、 func(var) での検索と置換はうまく機能しません。