[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: MORE INFO (Re: What is the difference between dynamic and static_cast)
From:       Malte.Starostik () t-online ! de (Malte Starostik)
Date:       2000-11-09 7:58:20
[Download RAW message or body]

Am Donnerstag,  9. November 2000 08:33 schrieb Thomas Leitner:
> O.k. I was talking to my Compaq C++ contact and he came up with this below
> (it's a reply from me to him, to avoid confusion) The main question seems
> to be:
>
> Is it legal to dynamic_cast from a base_class* to a derived_class* ?
That's what it is for, a cast from derived* to base* is implicit like
KMFolderTreeItem *derived
QListViewItem *base = derived; // no cast needed
See also 
http://users.utu.fi/sisasa/oasis/cppfaq/basics-of-inheritance.html#[19.4]

static_cast and dynamic_cast serve the purpose to be able to cast from base* 
to derived*.
With static_cast the programmer as to assure that the base* pointer provided 
is in fact of type derived*
With dynamic_cast you can check if it is because dynamic_cast returns 0 if it 
is not.
See also http://www.icce.rug.nl/docs/cplusplus/cplusplus02.html#l17
and http://www.icce.rug.nl/docs/cplusplus/cplusplus16.html#l278

-Malte
 
>> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic