home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!rutgers!rochester!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!sm86+
- From: sm86+@andrew.cmu.edu (Stefan Monnier)
- Newsgroups: comp.lang.c++
- Subject: Getting type info back !
- Message-ID: <YeckhJS00awJ0JJJV7@andrew.cmu.edu>
- Date: 1 Sep 92 06:19:01 GMT
- Organization: Junior, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA
- Lines: 32
-
-
- I would like to store different type of objects in a 'generic' structure,
- using the (void *)
- The problem I'm faced with is that of determining the real type of an
- object after storing in that structure (when I take it back)
-
- It is a quite general question.
- Given a class T2 subclass of T1 and objects o2 and o1 of type
- respectively T2 and T1, you can safely do
-
- o1 = o2
-
- as o2 is of type T1, too. But how can I decide if
-
- o2 = o1
-
- is safe ? of course just o1=o2; o2=o1 IS safe, but in a more general
- situation, it is not. Eiffel has for this special case:
-
- o2 ?= o1
-
- If o1 is effectively of type T2 (and not only T1), then o2==o1, else, o2==NIL
-
- Is there something equivalent in C++ ?
-
-
- Stefan Monnier
-
-
- -----------------------------------------------------
- -- On the average, people seem to be acting normal --
- -----------------------------------------------------
-