Skavenger wrote in news:1102593940.551799.236980
@z14g2000cwz.googlegroups.com in comp.lang.c++:
> Hi,
> I'm attempting to use a class member function pointer to call a
> relevant function. This is done like this....
>
class SampleA; /* Meeded before the next line */
> typedef void(SampleA::*SAMPLEAFUNC)(void);
>
> class SampleA {
> public:
> SampleA() { memFunc = testFunc; }
SampleA() : memFunc( &SampleA::testFunc ) {}
> ~SampleB() {};
Did you mean ~SampleA() {}
Note the trailing ; isn't needed.
>
> void testFunc (void);
>
> SAMPLEAFUNC memFunc;
> }
>
> void main(void)
> {
> SampleA *a = new SampleA();
>
> (a->*memFunc)();
(a->*(a->memFunc))();
> }
>
> Unfortunately I get the error C2064: Term does not evealuate to a
> function when i try to call using the (a->*memFunc)(); statement.
>
BTW all upercase identifiers for eg: SAMPLEAFUNC, should be
reserved for *exclusive* use by the preprocessor (#define's), its
just a convention, but a convention *alot* of people abide by.
Rob.
--
http://www.victim-prime.dsl.pipex.com/