Jakym zpusobem muzu donutit vektor, abych do nej mohl vkladat objekty zalozene na jedne abstraktni tride?
Abych to priblizil...mam tridu entity a na te je zalozeno nekolik ruznych druhu entit (=trid dedicich tuhle tridu, ktere jiz samozrejme abstraktni nejsou). Docela potrebuju, abych to mohl mit v tom jednom vektoru.
Ted mam tenhle kod:
std::vector<entity> entities;
A dela to tenhle error:
c:\program files\microsoft visual studio 9.0\vc\include\vector(716) : error C2259: 'entity' : cannot instantiate abstract class
due to following members:
'void entity::loop(void)' : is abstract
c:\documents and settings\mzabsky\dokumenty\visual studio 2008\projects\gw\gw\entities.h(37) : see declaration of 'entity::loop'
'void entity::collide(entity)' : is abstract
c:\documents and settings\mzabsky\dokumenty\visual studio 2008\projects\gw\gw\entities.h(38) : see declaration of 'entity::collide'
c:\documents and settings\mzabsky\dokumenty\visual studio 2008\projects\gw\gw\core.cpp(18) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
with
[
_Ty=entity
]
Loop a Collide jsou ty virtualni funkce, ktere jsou u entity prazdne.
...nebo existuje nejaky jiny zpusob jak bych mohl potom prochazet vsechny objekty zalozene na entity?