次のコードを検討してください。
struct Foo
{
Foo operator+(const Foo &rhs) const;
// notice lack of: Foo operator*(const Foo &rhs) const;
};
template <class T>
struct Bar
{
T x, y;
T add() const { return x + y; }
T mul() const { return x * y; }
};
2つの質問があります:
何か意味のあるものから継承し
Bar<Foo>
てオーバーライドできますか?mul()
どこでも使用しない場合、
Bar<Foo>
オーバーライドせずに継承できますか?mul()
mul()