Difference between revisions of "Functor"
Jump to navigation
Jump to search
| Line 1: | Line 1: | ||
The term '''functor''' has two distinct meanings. | The term '''functor''' has two distinct meanings. | ||
| − | + | cumming on my face oh yes sweet milk | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
==In Computer Science== | ==In Computer Science== | ||
Revision as of 18:23, January 28, 2013
The term functor has two distinct meanings.
cumming on my face oh yes sweet milk
In Computer Science
In computer science, the term "functor" is short for "function operator", also called a "function object". It is essentially a class method with no name. Many modern programming languages support this. For example, in C++ one can define a function object with the "operator()" notation, that is, a definition of what parentheses mean after an object.
class C {
public:
int operator()(int i, int j) { return k+i*j; }
int k;
.....
};
.....
C MyObject;
MyObject.k = 3;
int r = MyObject(4,5);
.....
We have effectively defined a nameless method for class C. Instead of making a named invocation like "MyObject.func(4,5)", we just write "MyObject(4,5)".