Advanced C++ Programming
Duration: 5 days
C++ is possibly the richest programming language in common use, and it allows programmers to write code using three distinct styles: procedural, object-oriented, and generic. This course is aimed to take C++ programmers to a new level of understanding and competence in their use of the C++ language and libraries.
The course is divided into four parts: the first builds on existing knowledge, showing how to use basic language features correctly, and delegates will probably discover a number of things that they hadn't appreciated about the language and its use. The second section of the course covers templates, the language feature that underlies the Standard Template Library and most recent advances in C++. It is not an exaggeration to say that a thorough understanding of templates is essential in order to be a modern C++ programmer.
The third part majors on OO development, and shows how popular idioms and design patterns can be implemented in C++. The final two sections look at the two main libraries used by C++ programmers today: the Standard Template Library and the Boost libraries. The course will introduce both libraries, discuss their main features, and show how to use them.
Unlike some "advanced" courses, this one does cover complex and advanced material. It is essential that delegates possess a good basic knowledge (and have practical experience) of OO programming in C++. As well as being comfortable with the basic syntax, you should be familiar with declaring, defining and using classes, inheritance, and dynamic memory management.
The class involves a lot of practical work, so delegates should come along prepared to get coding. The course can be run using either GCC on Linux (or OS X), or Microsoft Visual Studio on Windows.
Course Content
Part 1: Using Language Features Correctly
Const and Casting
- Const correctness
- Overloading on const
- C++ cast operators
- mutable
- Standard conversions
- Converting constructors
- User-defined conversions
- Namespaces
- Koenig lookup
- Nested types
- Throwing and catching correctly
- Exception-safe code
- The new_handler
- Placement new
- Overloading new and delete
Part 2: Templates
Template Functions
- Introduction to templates
- Implementing template functions
- Template instantiation
- Creating a template class
- Template class instantiation
- Non-type template parameters
- Specialization
- Template template parameters
Part 3: Idioms and Design Patterns
Implementing Value Types
- What are value types?
- Construction and destruction
- Copying and assignment
- Operator overloading
- The Bridge design pattern
- Using Bridge to decouple compilation
- Implementing handle/body
- What are functors?
- Implementing and using functors
- What are smart pointers?
- Uses of smart pointers in C++
- Implementing a simple smart pointer
- Reference counting and smart pointers
- std::auto_ptr
- The Singleton design pattern
- A naive implementation
- Problems with singletons in C++
- Controlling singleton lifetimes
Part 4: The Standard Template Library
STL Concepts
- Concept-based programming
- Containers
- Iterators
- Algorithms
- Sequence containers
- Associative containers
- Adapters
- The Iterator design pattern
- Iterator concepts in STL
- Iterators and containers
- Implementing and using iterators
- Stream iterators
- STL standard algorithms
- Creating your own algorithms
Part 5: The Boost Libraries
Introduction to Boost
- What is Boost?
- Obtaining and installing Boost
- Overview of the Boost libraries
- boost::tuple
- boost::any
- boost::ref
- Smart pointers
- boost::bind
