From kde-core-devel Tue Nov 02 19:59:36 1999 From: Harri Porten Date: Tue, 02 Nov 1999 19:59:36 +0000 To: kde-core-devel Subject: Re: KPresenter X-MARC-Message: https://marc.info/?l=kde-core-devel&m=94157378018526 Waldo Bastian wrote: > > On Tue, 02 Nov 1999, Stephan Kulow wrote: > > Reginald Stadlbauer wrote: > > > > > > On Mon, 01 Nov 1999, Dirk A. Mueller wrote: > > > >Reginald Stadlbauer wrote: > > > > > > > >> KPresenter uses dynamic_casts. SO does it mean I have to switch all > > > >> back to C-casts now (would be lots of work :-(( ) > > > > > > > >errm, if const_casts would work, why don't use them? they're faster! :) > > > > > > Who says const_casts would work. > > > > > > I mean, you can always live without C++ casts, because > > > > > > dynamic_cast( aPtr )->doSomething() > > > > > > can be replaced by > > > > > > ( (AClass*)aPtr )->soSomething(). > > > > > > Itīs just that the first (C++) solution is the better one. > > > > > Hmm, but dynamic_cast will return 0 while (AClass*) will just > > do _something_. :) > > So if you don't check anything, a dynamic_cast'ed pointer will fail the > first time after it gets dereferenced and the C-styles casted pointer > will happily continue to appear valid and will most like result in a > crash further on in the program. > > Question: Which type of fault is easier to debug? Additionally the C++ type casts are much stricter, i.e. disallow accessing private members by casting to a base class that was inherited "private". Harri.