473,394 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

returning a pointer to a member function

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 ***
Mar 9 '06 #1
2 1421
> 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 ***
Mar 9 '06 #2
Fraser Ross wrote:
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.

--

Pete Becker
Roundhouse Consulting, Ltd.
Mar 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Gent | last post by:
I have two questions which are very similar: Is it possible to return an object in C++. Below is part of my code for reference however I am more concerned about the concept. It seems like the...
11
by: Justin Naidl | last post by:
class Foo { protected: char foo_stuff; public: char* get_foo_stuff(); } Given the above example. What I want to know is the "proper/standard" way
17
by: djcredo | last post by:
Hey all, I want to return a pointer to a struct. Here is what I'lm trying to do: struct Position{ int x; int y; }; Position* GraphicTag::getRenderCentre(){
23
by: pauldepstein | last post by:
Below is posted from a link for Stanford students in computer science. QUOTE BEGINS HERE Because of the risk of misuse, some experts recommend never returning a reference from a function or...
5
by: ctj951 | last post by:
I have a very specific question about a language issue that I was hoping to get an answer to. If you allocate a structure that contains an array as a local variable inside a function and return...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.