Skip to Main Content
Professional C++, 6th Edition
book

Professional C++, 6th Edition

by Marc Gregoire
February 2024
Intermediate to advanced content levelIntermediate to advanced
1376 pages
40h 6m
English
Wiley
Content preview from Professional C++, 6th Edition

19Function Pointers, Function Objects, and Lambda Expressions

Functions in C++ are first-class functions, as functions can be used in the same way as normal variables, such as passing them as arguments to other functions, returning them from other functions, and assigning them to variables. A term that often comes up in this context is a callback, representing something that can be called. It can be a function pointer or something that behaves like a function pointer, such as an object with an overloaded operator(), or an inline lambda expression. A class that overloads operator() is called a function object, or functor for short. Conveniently, the Standard Library provides a set of classes that can be used to create callback objects and to adapt existing callback objects. Lambda expressions allow you to create small inline callbacks right at the place where you need them, which improves the readability and maintainability of your code. It's time to take a closer look at the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming: Principles and Practice Using C++, 3rd Edition

Programming: Principles and Practice Using C++, 3rd Edition

Bjarne Stroustrup
C++ Primer, Fifth Edition

C++ Primer, Fifth Edition

Stanley B. Lippman, Josée Lajoie, Barbara E. Moo

Publisher Resources

ISBN: 9781394193172