Lecture overview -- Keyboard shortcut: 'u'  Previous page: The for-each algorithm -- Keyboard shortcut: 'p'  Next page: Using the sort algorithm -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 5 - Page 35 : 39
Notes about C++
Templates and The Standard Library
Function objects

A function object (function-like object or functor) is a an object with an application operator, operator()

  • The C++ Programming Language: Page 514-515, 287
 

y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/application-operator-overload/vers1/point.hClass Point with overloadings of the application operator.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/application-operator-overload/vers1/point.ccDefinition of Point application operators.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/application-operator-overload/vers1/prog.ccSample uses of the application operators - Funny and artificial.


As another example, we provide access to x and y in point p via p(1) and p(2)

y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/application-operator-overload/vers2/point.hClass Point with another overloading of the application operator.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/application-operator-overload/vers2/point.ccDefinition of then Point application operator.


y:/Kurt/Files/Advanced-programming-cpp/cpp/kn/application-operator-overload/vers2/prog.ccSample uses of the application operators - slightly more realistic.