Click here to Skip to main content
15,880,608 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have an Entity class where I am adding components like this -
C++
CTransform transform;
ent.addComponent(&transform);


And
C++
void addComponent(CComponent* component);

template<typename T>
T* getComponent(E_COMPONENT_TYPE type)
{
    return dynamic_cast<T*>(mComponents[type]);
}


Now when I try to get a component like -
C++
CTransform* trans = getComponent<CTransform>(ECT_TRANSFORM);


I am getting error in dynamic_cast.

Thanks in advance.
Posted
Comments
ExGunner 2-Sep-15 3:23am    
I manage to solve it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900