Can someone help me out. I haven't dealt with pointer function
much. Here is the class definition for which it resides, although its
only part of it.
template<typename Type>
class vec2D
{
private:
bool (*drawFunc)(unsigned int ID);
unsigned int Col_id;
public:
//Enables each object member to have its own unique draw func.
void setDrawFunc( bool(*Pf)(unsigned int) ) { drawFunc = &Pf; }
///some more stuff
}
};
Inside another class I have this
class AnotherClass {
enum BlockType { LINE,SQUARE, ZSHAPE, LSHAPE, TSHAPE, CSHAPE, MAX_SHAPE };
vec2D<float> ShapePos[MAX_SHAPE];
bool myCheckValidID(unsigned int Col_Id);
bool drawLine(unsigned int Color_ID);
bool drawSquare(unsigned int Color_ID);
bool drawZShape(unsigned int Color_ID);
bool drawLShape(unsigned int Color_ID);
bool drawTShape(unsigned int Color_ID);
public : AnotherClass();
};
In the constructor I tried to assign the function to its function
pointer like so :
AnotherClass::AnotherClass(){
//For refrence
// enum BlockType { LINE,SQUARE, ZSHAPE, LSHAPE, TSHAPE, CSHAPE, MAX_SHAPE };
ShapePos[LINE].setDrawFunc(&Tetris::drawLine);
}
But this gives me a conversion error. How could I pass the function
correctly to setDrawFunc