By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,750 Members | 1,165 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,750 IT Pros & Developers. It's quick & easy.

typedef'ing Function Pointers

P: n/a
Hey all,

Another creative question: is it possible to do something like this to type
define a pointer to a specific type of function:

typedef bool (*)(std::string::const_iterator,
std::string::const_iterator) ItCompare;

And if so, how? The above example does not work, btw, I'm just wondering if
there is a way.

- JFA1
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Try

typedef bool (*ItCompare)
(
std::string::const_iterator,
std::string::const_iterator
);

James Aguilar wrote:
Hey all,

Another creative question: is it possible to do something like this to type
define a pointer to a specific type of function:

typedef bool (*)(std::string::const_iterator,
std::string::const_iterator) ItCompare;

And if so, how? The above example does not work, btw, I'm just wondering if
there is a way.

- JFA1


Jul 23 '05 #2

P: n/a
"James Aguilar" <jf**@cec.wustl.edu> wrote in message
news:d2**********@newsreader.wustl.edu...
Hey all,

Another creative question: is it possible to do something like this to
type define a pointer to a specific type of function:

typedef bool (*)(std::string::const_iterator,
std::string::const_iterator) ItCompare;

And if so, how? The above example does not work, btw, I'm just wondering
if there is a way.


I solved this one on my own just after asking. For those who want to know,
the syntax is like this:

typedef bool (*ItCompare)(std::string::const_iterator,
std::string::const_iterator);
Jul 23 '05 #3

P: n/a
James Aguilar wrote:
Hey all,

Another creative question: is it possible to do something like this to type
define a pointer to a specific type of function:

typedef bool (*)(std::string::const_iterator,
std::string::const_iterator) ItCompare;

And if so, how? The above example does not work, btw, I'm just wondering if
there is a way.

As with other typedefs for pointers to functions, the new type alias
should be together with the *:
typedef bool (*ItCompare)(std::string::const_iterator,
std::string::const_iterator);

--
Ioannis Vranos

http://www23.brinkster.com/noicys
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.