rcb@ccpv1.ncsu.edu (Randy Buckland) (02/14/90)
Is it possible in C++ to determine if an object is a member of a certain subclass? For example: ---------------------------------------------------------------------------- class foo { ... }; class bar : public foo { ... }; foo *aFunction (); code() { foo *a_foo; bar *a_bar; a_foo = aFunction(); /*********** Here's what I want to do **************/ if (is_class (a_foo, foo)) { ... } } ---------------------------------------------------------------------------- What I want to be able to do is to have an object that can contain a set of objects of type "foo" or one of it's subclasses. I will have operations that can be done to all members of the set and all classes based on "foo" will support. This I can do. However, I want to be able to extract an object from the set and if it is really a member of the subclass, call an extra method that only the subclass supports. I could brute force it with a variable/function that hold's the object type, but this seems wasteful. (Oh for a real, compiled, OO language on ultrix. Eiffel does not qualify since it break's every time I use it.) Randy Buckland rcb@ncsuvx.ncsu.edu