CObArray with different data types

I'm setting up a CObArray to handle multiple data types.  For instance I have a CLaser class derived from CObject and a CSerial class derived from CObject.  Let's say I place both of these objects into a CObArray object, let's call it m_DeviceArray.  Now I want to populate a list box on screen that will tell me what objects are in the array.  How could I do this?  How could I determine the object type on the fly?  I don't know what the object at element 0 is...or the object at element 5 is...but I want to "dump" the object onto the screen.
jstephe1Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
chensuConnect With a Mentor Commented:
Call CObject::GetRuntimeClass. Note that this function requires use of the IMPLEMENT_DYNAMIC or IMPLEMENT_SERIAL macro in the class implementation.
0
 
jstephe1Author Commented:
Thanks.  Now, to take it a little bit further.  Is there a way to access a data member within that?  For instance, if the CSerial class has a com port variable set to "com2".  Is there a way for me to get that data and place it on screen?
0
 
chensuCommented:
Yes, cast the pointer (CObject *) to CSerial *.
0
 
jstephe1Author Commented:
Thanks a lot.
0
All Courses

From novice to tech pro — start learning today.