POV-Ray : Newsgroups : povray.off-topic : Standard libraries : Re: Standard libraries Server Time
6 Sep 2024 11:18:12 EDT (-0400)
  Re: Standard libraries  
From: Fredrik Eriksson
Date: 8 Mar 2009 19:49:45
Message: <op.uqhy5foy7bxctx@e6600>
On Mon, 09 Mar 2009 00:33:32 +0100, Nicolas Alvarez  
<nic### [at] gmailcom> wrote:
>
> void foo(Alpha* ptr) {
>     Beta* beta = dynamic_cast<Beta*>(ptr);
> }
>
> If ptr is a Beta object that was (maybe implicitly) cast to a Alpha*,  
> then
> beta is now equal to ptr (except its type is Beta*, so you can use Beta
> members). If ptr actually pointed to an Alpha, or a Delta (another  
> subclass
> of Alpha), then the cast will throw a std::bad_cast exception.

No. A failed dynamic_cast of a pointer simply returns a null pointer. Only  
failed casts of a reference result in a std::bad_cast exception.


-- 
FE


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.