I'm not sure why I'm getting a segfault in this very simple code. I'm just playing around trying to get a feel for member function pointers right now:
Code:#include <iostream> typedef unsigned char uchar; typedef unsigned int uint; struct AXS_CONTROL{ uint viewCostInfo(uint); uint viewHarvestInfo(); }; typedef uint(AXS_CONTROL::*cost)(uint); typedef uint(AXS_CONTROL::*harvest)(); uint AXS_CONTROL::viewCostInfo( uint n ){ std::cout << "Viewing cost information: " << n << ".\n"; return n; } uint AXS_CONTROL::viewHarvestInfo(){ std::cout << "Viewing harvest information.\n"; return 1; } #define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember)) int main(){ AXS_CONTROL axs; cost cst; uint ans = CALL_MEMBER_FN(axs,cst)(5); return 0; }



LinkBack URL
About LinkBacks


