Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Advanced C++ [Instructor Edition]

You're reading from   Advanced C++ [Instructor Edition] Master the technique of confidently writing robust C++ code

Arrow left icon
Product type Hardcover
Published in Oct 2019
Last Updated in Feb 2023
Publisher
ISBN-13 9781838821135
Length 762 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (5):
Arrow left icon
Gazihan Alankus Gazihan Alankus
Author Profile Icon Gazihan Alankus
Gazihan Alankus
Olena Lizina Olena Lizina
Author Profile Icon Olena Lizina
Olena Lizina
Rakesh Mane Rakesh Mane
Author Profile Icon Rakesh Mane
Rakesh Mane
Vivek Nagarajan Vivek Nagarajan
Author Profile Icon Vivek Nagarajan
Vivek Nagarajan
Brian Price Brian Price
Author Profile Icon Brian Price
Brian Price
+1 more Show less
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

About the Book 1. Anatomy of Portable C++ Software FREE CHAPTER 2A. No Ducks Allowed – Types and Deduction 2B. No Ducks Allowed – Templates and Deduction 3. No Leaks Allowed - Exceptions and Resources 4. Separation of Concerns - Software Architecture, Functions, and Variadic Templates 5. The Philosophers' Dinner – Threads and Concurrency 6. Streams and I/O 7. Everybody Falls, It's How You Get Back Up – Testing and Debugging 8. Need for Speed – Performance and Optimization 1. Appendix

Function Objects and Lambda Expressions

One common pattern used in programming, particularly when implementing event-based processing, such as asynchronous input and output, is the use of the callback. A client registers that they want to be notified that an event has occurred (For example: data is available to read, or a data transmission is complete). This pattern is known as Observer pattern or Subscriber Publisher pattern. C++ supports a variety of techniques to provide the callback mechanism.

Function Pointers

The first mechanism is the use of the function pointers. This is a legacy feature inherited from the C language. The following program shows an example of a function pointer:

#include <iostream>

using FnPtr = void (*)(void);

void function1()

{

    std::cout << "function1 called\n";

}

int main()

{

    std::cout << "\n\n------ Function Pointers ------\n";

    FnPtr fn{function1};

   ...

lock icon The rest of the chapter is locked
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Advanced C++ [Instructor Edition]
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Modal Close icon
Modal Close icon