Member function pointers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux