C ++では、オブジェクトの型が特定のクラスから継承されているかどうかを確認するにはどうすればよいですか?
class Form { };
class Moveable : public Form { };
class Animatable : public Form { };
class Character : public Moveable, public Animatable { };
Character John;
if(John is moveable)
// ...
私の実装では、if
クエリはForm
リストのすべての要素に対して実行されます。タイプが継承されるすべてのオブジェクトMoveable
は移動でき、他のオブジェクトが必要としないオブジェクトの処理が必要です。