WTF are functors, and how do they work?
Well, as the title says, what are they, and how do they work? A few good examples are welcome, aswell as a good tutorial on them. I didn''t understand the stuff on www.sgi.com about them.
In case you wanna know,someone told me it would be usefull to implement them in my win32 wrapper, instead of static functions.
Toolmaker
-Earth is 98% full. Please delete anybody you can.
I assume that you spelled wrong and are talking about functions?
If you are look below other wise forget this post.
--------------------------------
Functions are just as they sound, they carry out commands, etc.
For example:
you can find what your looking for easily.
If you are look below other wise forget this post.
--------------------------------
Functions are just as they sound, they carry out commands, etc.
For example:
int new_file(char *filename, char ipt[80]){ ofstream datafile001( filename ); datafile001 << ipt1 << endl; datafile001.close(); return(1);}////////////In your Game_Init functionnew_file("test.txt", "This is a test");
Tutorials would be good at http://www.functionx.com/you can find what your looking for easily.
summary: functor are objects with an operator() so they can be called like functions. The advantage is that they can have infromation associated with that object.
most common use to to write a mem_fun() functor.
most common use to to write a mem_fun() functor.
quote:Original post by demonrealms
I assume that you spelled wrong and are talking about functions?
If you are look below other wise forget this post.
--------------------------------
Functions are just as they sound, they carry out commands, etc.
For example:
Tutorials would be good at http://www.functionx.com/int new_file(char *filename, char ipt[80]){ ofstream datafile001( filename ); datafile001 << ipt1 << endl; datafile001.close(); return(1);}////////////In your Game_Init functionnew_file("test.txt", "This is a test");
you can find what your looking for easily.
No he didn''t spell it incorrectly, "functors" do exist you know.
In the C++ sense they are typesafe callbacks that work on member functions or regular function. Use Boost::Function with Boost::Bind to make them.
They mean something entirely different in ML.
Oh, and you still need static functions for Win32 callbacks.
[edited by - antareus on October 20, 2003 9:55:51 PM]
They mean something entirely different in ML.
Oh, and you still need static functions for Win32 callbacks.
[edited by - antareus on October 20, 2003 9:55:51 PM]
Well, I am not looking for callback functions . I am using oluseyi''s way of having a windows class and such. I am currently writing a pretty large wgBaseWindow class and I wanted to use functors for that. So I can do this:
And then pass the Click function into the message line. Is it possible that way?
Toolmaker
-Earth is 98% full. Please delete anybody you can.
class ExitButton{public: long Click(wgBaseWindow *Owner, wgBaseWindow *Me, WPARAM wParam, LPARAM lParam);};
And then pass the Click function into the message line. Is it possible that way?
Toolmaker
-Earth is 98% full. Please delete anybody you can.
If have a special RegisterEvent function to get fn pointers. However, the functions need to be static. How do I make then non-static, so I can just use class members without having the function static.
Toolmaker
Toolmaker
I just explained what you had to do but you shot back "I don''t need callbacks."
Make up your mind.
Make up your mind.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement