CS 1337 Lecture Notes - Lecture 19: London Academy Of Music And Dramatic Art, Special Functions

22 views2 pages

Document Summary

* function object - is an object that acts like a function. * a function or function object that returns a boolean value is called a predicate. = * a lamda expression is a compact way of creating a function object without writing a class declaration. * creating an expression that contains only the logic would be in the overloaded () member function. * when the compiler sees this special function, it actually creates in memory the function object you left out. * [] - lambda introducer - it marks the beginning of the lambda object. * [](parameter list) {function body} class sum { public: function operator () * what makes is possible to create a function object is overloading the int operator()(int a, int b) { return a + b; vector v = {1, 2, 3, 3, 4, 4, 4, 5, 6}; Sum s1; cout << s1(1, 3) << endl; cout << count_if(v. begin(), v. end(), e1) << endl;

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents