问题
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