im trying to create a member function pointer, but the problem is that i need to make that pointer a member of the class as well. heres a sample of what im trying to:
Code://gfxclass.h class gfxclass { public: //this is my member function pointer int (gfxclass::*RGB)(int, int, int); int initgfx(void); private: //here are the two functions it could point to int gfx1(int r, int g, int b); int gfx2(int r, int g, int b); };Code://gfxclass.cpp #include "gfxclass.h" int gfxclass::init(void) { if(whatever) RGB = gfx1; else RGB = gfx2; } int gfxclass::gfx1(int r, int g, int b) { //whatever, do stuff } int gfxclass::gfx2(int r, int g, int b) { //whatever }when i go to compile, i get an undeclared identifier error on my call to RGB. ive managed to get it to compile with the member function pointer not being part of the class, but i need it to be a member. any help would be appreciatedCode://main.cpp #include "gfxclass.h" gfxclass gclass; int main() { gclass.init(); int temp = (gclass.*RGB)(0,0,0); return 0; }



LinkBack URL
About LinkBacks


