Solution for object identity
-
Hail, dear colleagues. I have a question about object identity. Let's say I need to make an array of some objects. These objects (classes) will be defined by users of the library. So, I have to provide a base class with an interface and create an array of these objects. It's clear. But when user creates a derived class and wants to get an object from the array, he should know about type of this object to be able to cast it back, because in this array objects of different types can be stored. So, the question is, how to define identity of derived class? Should I implement something like IsKindOf() method and use runtime identification, like in MFC, or there are other ways to do so? I have to mention that the only extension, which can be used, is STL. No MFC, nor any other platform depended libraries. Thank you in advance for any suggestions.
-
Hail, dear colleagues. I have a question about object identity. Let's say I need to make an array of some objects. These objects (classes) will be defined by users of the library. So, I have to provide a base class with an interface and create an array of these objects. It's clear. But when user creates a derived class and wants to get an object from the array, he should know about type of this object to be able to cast it back, because in this array objects of different types can be stored. So, the question is, how to define identity of derived class? Should I implement something like IsKindOf() method and use runtime identification, like in MFC, or there are other ways to do so? I have to mention that the only extension, which can be used, is STL. No MFC, nor any other platform depended libraries. Thank you in advance for any suggestions.