This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Member function pointers
- From: "Rune Torgersen" <runet at innovsys dot com>
- To: <gcc-help at gcc dot gnu dot org>
- Date: Tue, 24 May 2005 09:30:02 -0500
- Subject: Member function pointers
I have a piece of code that worked perfectly under GCC 3.3.3, but fails
to even compile under GCC 3.4.3
class testfnptr
{
public:
bool (testfnptr::*func)(void);
testfnptr() {func = 0; };
bool dotest()
{
if (0 != (this->*func))
{
(this->*func)();
}
}
};
int main()
{
testfnptr testing;
testing.dotest();
return 0;
}
What I'm trying to do is to check if a member-function pointer is NULL
before I call the function. (In my real application I have a function
table that I go through, and some entries are set to NULL)
GCC 3.4 3 says:
testfnptr.cpp: In member function `bool testfnptr::dotest()':
testfnptr.cpp:11: error: invalid use of non-static member function
I have tried to check func directly, but that variable always have a
value != 0.
Rune Torgersen
System Developer
Innovative Systems LLC
1000 Innovative Drive
Mitchell, SD 57301
Ph: 605-995-6120
www.innovsys.com