Book Image

The Modern C++ Challenger

By : Brent Arnold, Kristian Secor
Book Image

The Modern C++ Challenger

By: Brent Arnold, Kristian Secor

Overview of this book

C++ is one of the most widely-used programming languages and has applications in a variety of fields, such as gaming, GUI programming, and operating systems, to name a few. Through the years, C++ has evolved into one of the top choices for software developers worldwide. You’ll begin your challenge with various math problems, including Armstrong numbers. As you progress through the course, the complexity of the challenges will increase. You’ll write a class template that represents a two-dimensional array container. You’ll also write a program to find files in a directory that match a regular expression. While tackling algorithms and data structures, you’ll create buffers and print histograms. Things will get tougher when you’ll write code to implement a general-purpose parallel algorithm using asynchronous functions. Whether it is creating an EAN-13 barcode generator or encrypting and decrypting files, this course will put your skills to test and in turn teach you several new features of C++.
Table of Contents (10 chapters)
Chapter 6
Design Patterns
Content Locked
Section 6
Level 6 - Problem 5
Write a class template that behaves like a vector but can notify registered parties of internal state changes. The class must provide at least the following operations: - Various constructors for creating new instances of the class - operator= to assign values to the container - push_back() to add a new element at the end of the container - pop_back() to remove the last element from the container - clear() to remove all the elements from the container - size() to return the number of elements from the container - empty() to indicate whether the container is empty or has elements - operator=, push_back() , pop_back() , and clear() must notify others of the state changes. The notification should include the type of the change, and, when the case, the index of the element that was changed (such as added or removed).