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

2019-09-14 21:41发布

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.

2条回答
叛逆
2楼-- · 2019-09-14 22:01

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.

查看更多
beautiful°
3楼-- · 2019-09-14 22:18

I found that this works just fine!

 Type^ meh = element->GetType();
查看更多
登录 后发表回答