0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Effective C++ > 27項 > dynamic_castが必要になる時の問題を避ける方法

0
Last updated at Posted at 2015-05-11

引用: Effective C++ 第3版

dynamic_castが必要になるのは、派生クラスのオブジェクトを操作するのに、その基底クラスのポインタか参照しか持たないときです。この問題を避けるのには、一般に、2つの方法があります。
...
まず、はじめから「派生クラスのポインタ(...)のみを格納するコンテナ」を用意し、使う方法です。
...
もう一つの方法は、派生クラスで定義するすべての関数を仮想関数として基底クラスに持たせ、その関数を使って派生クラスを操作するというものです。

上記に関係しそうなものとしては
SO:1
SO:2

関連キーワード?

  • covariant return types @ SO:2
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?