From kde-core-devel Mon Nov 01 23:12:06 1999 From: Don Sanders Date: Mon, 01 Nov 1999 23:12:06 +0000 To: kde-core-devel Subject: Re: KPresenter X-MARC-Message: https://marc.info/?l=kde-core-devel&m=94149900832578 On Tue, 02 Nov 1999, Reginald Stadlbauer wrote: > On Mon, 01 Nov 1999, Kurt Granroth wrote: > >Reginald Stadlbauer wrote: > >> 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. > > > >Why is it better? I'll admit that I've never used dynamic_cast before > >as I couldn't see the point. > > dynamic_casts do typechecking. So, if it fails, it returns a NULL-pointer. > AFAIK a C cast would just segfault. But as I donīt check the result of each > dynamic_cast the result is the same :-) > > And to be honest: Iīm not using dynamic_casts anymore, but I just donīt want > to go over all the KPresenter and KWord sources and revert the casts :-) Considered using static_cast? Isn't it recommended for solving exactly the problem being experienced? I'm using static_cast as the programmers FAQ said don't use dynamic_cast unless you have to, and I didn't want to use C style casts, as I was under the impression that would mean I would burn in hell for all eternity. The search/replace expression would be simpler and quite probably revertable (you don't have any variables name dynamic_cast do you?). BFN, Don.