c++ - Static member array of pointers to member functions -



i trying define in .cpp file attribute should array of pointers member functions of class named hand.
both array , functions members of hand , array static(please correct me if should not).
this reached:

static bool hand::*(hand::hfunctions)[] ()= {&hand::has_sflush,&hand::has_poker,&hand::has_full,&hand::has_flush, &hand::has_straight,&hand::has_trio,&hand::has_2pair,&hand::has_pair};                                               


i error: hand.cpp:96:42: error: declaration of ‘hfunctions’ array of functions.
i guess type definition worng need know how can make definition right

the syntax rather convoluted one:

class hand {     bool has_sflush();     static bool (hand::*hfunctions[])();     ... };  bool (hand::*hand::hfunctions[])() = {&hand::has_sflush, ...}; 

a way gradually increasing complexity, using cdecl.org check @ each step:

int (*hfunctions)() 

declare hfunctions pointer function returning int


int (hand::*hfunctions)() 

declare hfunctions pointer member of class hand function returning int

warning: unsupported in c -- 'pointer member of class'


int (hand::*hfunctions[])() 

declare hfunctions array of pointer member of class hand function returning int

warning: unsupported in c -- 'pointer member of class'


now replace int bool (sadly, cdecl.org doesn't understand bool); syntax of declaration.

for definition, replace hfunctions hand::hfunctions, , add initialization part, did.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -