私はC++(C ++ 11)のテンプレート・シェナニガンを調べています。私が欲しいのは、抽象クラスの純粋な仮想型です。これはScalaの抽象型のようになります。C ++では、次のようなことをしたいと思います。
struct Base {
// Says any concrete subclass must define Type, but doesn't
// require that it be anything in particular.
virtual typedef MyType;
};
struct Derived : Base {
// Won't compile unless this typedef exists.
typedef int MyType;
};
これを行う方法はありますか?