returning a pointer to a member function

F

Fraser Ross

Can someone remind me of the syntax for a function that returns a
pointer to a member function? The functions are going to be defined at
the declaration. They will take no parameters. I've given the pointer
members here.

TColor const (TuserInterface::*
pointerToGetPointColourFunction_)(unsigned int const) const;

TColor const (TuserInterface::*
Get_GetPointColourFunctionPointer())((unsigned int) const) const {
return pointerToGetPointColourFunction_;
};




void (TuserInterface::* pointerToSetPointColourFunction_)(unsigned int
const, TColor const) const;

void (TuserInterface::* Get_SetPointColourFunctionPointer())((unsigned
int, TColor) const) {
return pointerToSetPointColourFunction_;
};


*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***
 
F

Fraser Ross

TColor const (TuserInterface::*
pointerToGetPointColourFunction_)(unsigned int const) const;

TColor const (TuserInterface::*
Get_GetPointColourFunctionPointer())((unsigned int) const) const {
return pointerToGetPointColourFunction_;
};
TColor const (TuserInterface::* Get_GetPointColourFunctionPointer()
const)(unsigned int) const {
return pointerToGetPointColourFunction_;
};
The pointed to function is constant. I appear to have had a syntax
mistake with the constness.

void (TuserInterface::* pointerToSetPointColourFunction_)(unsigned int
const, TColor const) const;

void (TuserInterface::* Get_SetPointColourFunctionPointer())((unsigned
int, TColor) const) {
return pointerToSetPointColourFunction_;
};
void (TuserInterface::* Get_SetPointColourFunctionPointer())(unsigned
int, TColor) {
return pointerToSetPointColourFunction_;
};
A similar syntax mistake here I think.


*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***
 
P

Pete Becker

Fraser said:
Can someone remind me of the syntax for a function that returns a
pointer to a member function?

typedef void (MyClass::*pmf)(int);
pmf func()
{
return &MyClass::mem_func;
}

If for some reason you don't want to use a typedef, you're on your own.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top