Sessions on advanced C++ techniques
Half-day seminars at CCC
Author: Zoltán Porkoláb
Budapest, 2007
Topics
- A.1. Constant magic
Everything you want to know about constants. Pointer to constants,
constant members and constant memberfunctions. Const_cast
and mutable. When phisical and logical constants are
different?
- A.2. Pointers and references
Prereq: A.1.
What is the concept behind reference? Left values. What is the
difference between pointers and references?
Parameters passed by reference, functions returning reference.
Constant reference. Reference and polymorphism.
- A.3. Constructors and destructors
Prereq: A.1. A.2
Life-categories in C++. When objects are allocated and when initialized?
Constructors for conversions and to create temporaries. The
explicit keyword. Destructors, virtual destructors.
Virtualize constructors: cloning. Copy constructor and
assignment operator. Reference counting technique. Constructors and
access levels: protected and private constructors
or destructors.
- A.4. Advanced memory handling
Prereq: A.2. A.3.
Memory-models in C++. New and delete operators. Constructors,
exceptions and memory-leaks. The auto_ptr - and when
it does not help. Write your own smart pointer. Arrays are not
polymorphic! C++ object internals.
- A.5. Templates
Template basics. Instantiation, parameter deduction.
specialization, user specialization. Template overloading.
Case studies: a template stack and a template
matrix. Friends for templates.
- A.6. STL fundamentals
Sequential containers: vector, deque, list. Standard
typedefs, constructors, update operations. Adaptors. Associative
containers: map, multimap, set, multiset. Special operations
on associative containers. Algorithms. Iterators. STL guaranties.
Examples. Effective STL usage, and frequent mistakes.
- A.7. Compiling and linking issues
Everything on project organization issues. The PIMPL and the Firewall
compiling idioms. Minimalize dependencies between classes. Compilers,
compatibility issues. Static and dinamic linking. How to organize
templates.
Bibliography
Links