Groups | Blog | Home
all groups > visual c > january 2004 >

visual c : VS7.1: No member function pointer call possible?



Doug Harrison [MVP]
1/29/2004 11:44:05 AM
[quoted text, click to view]

Try:

(a.*a.pfnc)();

P.S. For functions which have no parameters, it's conventional in C++ to
omit the "void", because in C++, an empty parameter list means "void".

--
Doug Harrison
Igor Tandetnik
1/29/2004 12:37:12 PM
[quoted text, click to view]

Should be

A::A(void) : pfnc(&A::fn) {}

[quoted text, click to view]
***

Should be

(a.*(a.pfnc))();

[quoted text, click to view]

--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken

Axel Dahmen
1/29/2004 6:33:58 PM
Hi,

I can't get to compile the following:


struct A
{
A(void);
bool fn(void);
bool (A::*pfnc)(void);
};


A::A(void) : pfnc(fn) {}


bool A::fn(void) {return true;}


int _tmain(int argc, _TCHAR* argv[])
{
A a;
(a.*pfnc)(); // *** error: 'pfnc': undeclared identifier ***
return 0;
}

Is it me?? This ought to be correct C++ syntax. What am I doing wrong?

TIA,
Axel Dahmen

AddThis Social Bookmark Button