Hi,
I was curious whether or not to use the & operator when creating a
function pointer. It seems, that both &func and plain func create a
pointer of the appropriate function pointer type.
However, for member function pointers it seems that the use of & is
mandatory, the following code compiles but does not when uncommenting
the initialization of c:
class A
{
public:
static void foo();
void bar();
};
void A::foo()
{}
void A::bar()
{}
int main()
{
typedef void (*func)();
func a(A::foo);
func b(&A::foo);
typedef void (A::*memfunc)();
//memfunc c(A::bar);
memfunc d(&A::bar);
return 0;
}
Is there a rationale behind this "inconsistency"? What would you
recommend as the correct way to retrieve a pointer of an static
function, with or without &?
Yours,
Daniel
--
Got two Dear-Daniel-Instant Messages
by MSN, associate ICQ with stress--so
please use good, old E-MAIL!