I’m trying to make a function that takes two data types, each of which I know will be a descendent of a drawable class, meaning my function depends on some of drawable‘s functions. However because it is a template function I can’t do this.
How can I make it so I can use these descendant class functions? Or make it so only descendents of drawable are accepted?
here’s the beginning of my function. GetPositionY is drawable’s function.
template<typename T, typename T2>
bool CheckCollision(T* obj1, T2* obj2){
obj1->GetPositionY;
A
CheckCollision()function shall require the client to pass an object that providesGetPosition()methods. That’s what you do when callingobj1->GetPositionX()inside your template. There’s no reason to force it to pass adrawableobject.