From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3d313337c39c5dd5 X-Google-Attributes: gid103376,public From: fjh@cs.mu.oz.au (Fergus Henderson) Subject: Re: run-time type identification Date: 1998/09/03 Message-ID: <6sm6p9$h9n$1@mulga.cs.mu.OZ.AU>#1/1 X-Deja-AN: 387484396 References: <01bdd72e$49ee66b0$f330ea9e@ukp03332> <01bdd73c$082f0230$f330ea9e@ukp03332> Organization: Computer Science, The University of Melbourne Newsgroups: comp.lang.ada Date: 1998-09-03T00:00:00+00:00 List-Id: "Bob Fletcher" writes: >Yeah, this is the problem, there's no way of ensuring the safety of the >operation. What's wrong with trying the operation, and catching the exception if it fails? >The C++ dynamic_cast operator returns a zero (null) pointer if the >object being pointed to is not of the correct class. That's only half the story. In C++, if you use `dynamic_cast' to cast to a pointer type, it will return a null pointer if the cast fails. But if you use `dynamic_cast' to cast to a reference type, it will throw an exception (of type `std::bad_cast') if the cast fails. -- Fergus Henderson | "I have always known that the pursuit WWW: | of excellence is a lethal habit" PGP: finger fjh@128.250.37.3 | -- the last words of T. S. Garp.