They are not. static_cast exists for purpose.
On Wed, May 22, 2013 at 10:10 AM, Constantin Makshin <cmaks...@gmail.com>wrote: > Well, C-style casts are still useful because, unlike dynamic_cast, they > need neither RTTI nor run-time checks, making the compiled code somewhat > smaller and faster. You just need to be very careful with them. :-) > On May 22, 2013 8:52 PM, "Jonathan Greig" <redteam...@gmail.com> wrote: > >> Thank you André. The dynamic_cast worked perfectly. I'm from a C >> background and have been doing C-style casts for years without any major >> problems. Apparently this guy has also:) >> http://stackoverflow.com/questions/28002/regular-cast-vs-static-cast-vs-dynamic-cast >> >> - Swyped from my droid. >> >> On May 22, 2013 9:21 AM, "André Somers" <an...@familiesomers.nl> wrote: >> >> Op 22-5-2013 16:03, Jonathan Greig schreef: >> >>> BaseObject* base = (BaseObject*)item; >>> if(base) { base->setObjectRubberPoint(**key, point); } >>> >> The above looks suspicious. The cast you're doing here is unsafe. Your >> check on base on the second line is useless, as the C-style cast you're >> using doesn't do any checking. So, my suspicion is that your item isn't a >> BaseObject, and thus the method call you make into it is going to fail. Use >> a dynamic_cast<BaseObject*>(**item) for your cast instead. That cast _ >> will_ result in a 0 pointer if the cast fails. >> >> >> >> André >> >> -- >> You like Qt? >> I am looking for collegues to join me at i-Optics! >> >> >> _______________________________________________ >> Interest mailing list >> Interest@qt-project.org >> http://lists.qt-project.org/mailman/listinfo/interest >> >> > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest > >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest