[Interest] Container members in abstract base class?
André Somers
andre at familiesomers.nl
Wed May 22 16:21:13 CEST 2013
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!
More information about the Interest
mailing list