Conversion from void* to the pointer of the base class

前端 未结 4 1979
时光取名叫无心
时光取名叫无心 2020-12-05 21:01

I have some hierarchy: base, derived classes and some structure storing user data as void*. That void can store both Base and Derived classes pointers. Main problem that I d

4条回答
  •  情书的邮戳
    2020-12-05 21:43

    Use dynamic_cast, it can dynamically tell you if the pointer points to a Base object or not.

提交回复
热议问题