c++ - Using different arguments for different functions -
i have class several different subclasses , i'm using virtual bool update of them std::list
. i'm wondering, though, if can utilize different arguments separate bools, subclasses behave differently , don't want accommodate of them providing useless data.
for (std::list<gameobject*>::iterator = renderobjects.begin(); != renderobjects.end(); ++it) { if(!(*it)->update(arguments)){cout<<"error";} }
is there way can rewrite code update()
function given arguments needs specific subclass it's beingness called with?
this hosts valuable info help you: http://www.cplusplus.com/forum/general/50090/
the gist want dynamic_cast , check if successful or not.
a simpler alternative add together string classid every class or subclass defines is. check classid string.
if (fooobj.classid == "fooclass") { // }
c++
No comments:
Post a Comment