F
Fred
Is there a way to determine the class of an object?
For instance, if I have an array of Animal instances, how do I extract
the items that are of subclass type Dog?
Java has the "instanceof" operator, but is there any way in C++ to
do this without each class having an instance variable with some
kind of unique identifier for the class (this would be OK for classes
that I create, but doesn't scale to third-party classses).
For instance, if I have an array of Animal instances, how do I extract
the items that are of subclass type Dog?
Java has the "instanceof" operator, but is there any way in C++ to
do this without each class having an instance variable with some
kind of unique identifier for the class (this would be OK for classes
that I create, but doesn't scale to third-party classses).