6
6

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.

C++での型のチェックと比較

Last updated at Posted at 2014-03-02
//任意のクラス内での自身の型名とhogeObjectの型名とを比較  ※.name()した方がよかったっけ??
const type_info& this_id = typeid(*this);
const type_info& client_id = typeid(*hogeObject);

//コンソールに出力
cout << bool(this_id == client_id) << endl;

[参考URL]

第50章 型チェック
http://www7b.biglobe.ne.jp/~robe/cpphtml/html03/cpp03050.html

オブジェクトの型を知る
http://wisdom.sakura.ne.jp/programming/cpp/cpp36.html

6
6
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
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?