C++/CX - Check the type of an object?

大憨熊 提交于 2019-12-11 18:23:38

问题


Is it possible to check the type of an object in C++/CX ?

I have a Vector of objects which derive from ICustomObject and as I enumerate the objects from the Vector, i'd like to know what the actual object type is. This is so that I know what properties of that object should be accessible to me.


回答1:


You can use dynamic_cast - if the object is an object of MyObjectType, the result will be non null, if it's another type, the result will be nullptr.




回答2:


I found that this works just fine!

 Type^ meh = element->GetType();


来源:https://stackoverflow.com/questions/16027483/c-cx-check-the-type-of-an-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!