Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ちょっと私はJavaのバックグラウンドから来て、C ++の本を読んでいて、typeid()がtype_infoのオブジェクトを返すと言っています。しかし、私が次のようなことをしようとすると、
type_info *x = typeid(somthing);
エラーが発生します:consttype_infoからtype_infoへの適切な変換が存在しません。
type_infoオブジェクトへの参照を取得する方法を教えてもらえますか?
typeid演算子はを返し ますconst type_info&。したがって、ポインタではなく、const参照が必要です。
typeid
const type_info&
const std::type_info &x = typeid(something);