This document is intended for knowledgeable users of C who would like to make the transition to C++. It is a guide for Frank's C++ programming courses, which are given yearly at the University of Groningen. As such, this document is not a complete C++ handbook. Rather, it serves as an addition to other documentation sources. If you want a hard-copy version of the C++ annotations: that's available in postscript, and other formats in our ftp-site.
If you want to be informed about new releases of the Annotations, please subscribe to the annotations mailing list.
Chapter 1: Overview of the chapters
Chapter 2: Introduction
2.0.1: History of the C++ Annotations
2.1: What's new in the C++ Annotations
2.1.1: The C++ Annotations mailing list
2.2: The history of C++
2.2.1: Compiling a C program by a C++ compiler
2.2.2: Compiling a C++ program
2.3: Advantages and pretensions of C++
2.4: What is Object-Oriented Programming?
2.5: Differences between C and C++
2.5.1: End-of-line comment
2.5.2: NULL-pointers vs. 0-pointers
2.5.3: Strict type checking
2.5.4: A new syntax for casts
2.5.5: The 'static_cast'-operator
2.5.6: The 'const_cast'-operator
2.5.7: The 'reinterpret_cast'-operator
2.5.8: The void argument list
2.5.9: The #define __cplusplus
2.5.10: The usage of standard C functions
2.5.11: Header files for both C and C++
2.5.12: The definition of local variables
2.5.13: Function Overloading
2.5.14: Default function arguments
2.5.15: The keyword typedef
2.5.16: Functions as part of a struct
Chapter 3: A first impression of C++
3.1: More extensions of C in C++
3.1.1: The scope resolution operator ::
3.1.2: cout, cin and cerr
3.1.3: The keyword const
3.1.4: References
3.2: Functions as part of structs
3.3: Several new data types
3.3.1: The `bool' data type
3.3.2: The `wchar_t' data type
3.3.3: The `string' data type
3.3.3.1: Operations on strings
3.3.3.2: Overview of operations on strings
3.4: Data hiding: public, private and class
3.5: Structs in C vs. structs in C++
3.6: Namespaces
3.6.1: Defining namespaces
3.6.1.1: Declaring entities in namespaces
3.6.1.2: A closed namespace
3.6.2: Referring to entities
3.6.2.1: The using directive
3.6.3: The standard namespace
3.6.4: Nesting namespaces and namespace aliasing
3.6.4.1: Defining entities outside of their namespaces
Chapter 4: Classes
4.1: Constructors and destructors
4.1.1: The constructor
4.1.2: The destructor
4.1.3: A first application
4.1.4: Constructors with arguments
4.1.4.1: The order of construction
4.2: Const member functions and const objects
4.3: The operators new and delete
4.3.1: Allocating and deallocating arrays
4.3.2: New and delete and object pointers
4.3.3: The function set_new_handler()
4.4: The keyword inline
4.4.1: Inline functions within class declarations
4.4.2: Inline functions outside of class declarations
4.4.3: When to use inline functions
4.5: Objects in objects: composition
4.5.1: Composition and const objects: const member initializers
4.5.2: Composition and reference objects: reference member
initializers
4.6: Friend functions and friend classes
4.7: Header file organization with classes
4.8: Nesting Classes
4.8.1: Defining nested class members
4.8.2: Declaring nested classes
4.8.3: Access to private members in nested classes
4.8.4: Nesting enumerations
Chapter 5: Classes and memory allocation
5.1: Classes with pointer data members
5.2: The assignment operator
5.2.1: Overloading the assignment operator
5.2.1.1: The function 'operator=()'
5.3: The this pointer
5.3.1: Preventing self-destruction with this
5.3.2: Associativity of operators and this
5.4: The copy constructor: Initialization vs. Assignment
5.4.1: Similarities between the copy constructor and operator=()
5.5: Conclusion
Chapter 6: More About Operator Overloading
6.1: Overloading operator[]()
6.2: Overloading operator new(size_t)
6.3: Overloading operator delete(void *)
6.4: Cin, cout, cerr and their operators
6.5: Conversion operators
6.6: The `explicit' keyword
6.7: Overloading the increment and decrement operators
6.8: Function Objects
6.8.1: Categories of Function objects
6.8.1.1: Arithmetic Function Objects
6.8.1.2: Relational Function Objects
6.8.1.3: Logical Function Objects
6.8.2: Function Adaptors
6.9: Overloadable Operators
Chapter 7: Abstract Containers
7.1: The `pair' container
7.2: Sequential Containers
7.2.1: The `vector' container
7.2.2: The `list' container
7.2.3: The `queue' container
7.2.4: The `priority_queue' container
7.2.5: The `deque' container
7.2.6: The `map' container
7.2.7: The `multimap' container
7.2.8: The `set' container
7.2.9: The `multiset' container
7.2.10: The `stack' container
7.2.11: The `hash_map' and other hashing-based containers
7.3: The `complex' container
Chapter 8: Static data and functions
8.1: Static data
8.1.1: Private static data
8.1.2: Public static data
8.2: Static member functions
Chapter 9: Classes having pointers to members
9.1: Pointers to members: an example
9.2: Initializing pointers to members
9.3: Pointers to static members
9.4: Using pointers to members for real
9.4.1: Pointers to members: an implementation
Chapter 10: The Standard Template Library, generic algorithms
10.1: Iterators
10.1.1: Insert iterators
10.1.2: istream iterators
10.1.3: ostream iterators
10.2: The 'auto_ptr' class
10.2.1: Defining auto_ptr variables
10.2.2: Pointing to a newly allocated object
10.2.3: Pointing to another auto_ptr
10.2.4: Creating an plain auto_ptr
10.2.5: The get() memberfunction
10.2.6: The reset() memberfunction
10.2.7: The release() memberfunction
10.3: The Generic Algorithms
10.3.1: accumulate()
10.3.2: adjacent_difference()
10.3.3: adjacent_find()
10.3.4: binary_search()
10.3.5: copy()
10.3.6: copy_backward()
10.3.7: count()
10.3.8: count_if()
10.3.9: equal()
10.3.10: equal_range()
10.3.11: fill()
10.3.12: fill_n()
10.3.13: find()
10.3.14: find_if()
10.3.15: find_end()
10.3.16: find_first_of()
10.3.17: for_each()
10.3.18: generate()
10.3.19: generate_n()
10.3.20: includes()
10.3.21: inner_product()
10.3.22: inplace_merge()
10.3.23: iter_swap()
10.3.24: lexicographical_compare()
10.3.25: lower_bound()
10.3.26: max()
10.3.27: max_element()
10.3.28: merge()
10.3.29: min()
10.3.30: min_element()
10.3.31: mismatch()
10.3.32: next_permutation()
10.3.33: nth_element()
10.3.34: partial_sort()
10.3.35: partial_sort_copy()
10.3.36: partial_sum()
10.3.37: partition()
10.3.38: prev_permutation()
10.3.39: random_shuffle()
10.3.40: remove()
10.3.41: remove_copy()
10.3.42: remove_if()
10.3.43: remove_copy_if()
10.3.44: replace()
10.3.45: replace_copy()
10.3.46: replace_if()
10.3.47: replace_copy_if()
10.3.48: reverse()
10.3.49: reverse_copy()
10.3.50: rotate()
10.3.51: rotate_copy()
10.3.52: search()
10.3.53: search_n()
10.3.54: set_difference()
10.3.55: set_intersection()
10.3.56: set_symmetric_difference()
10.3.57: set_union()
10.3.58: sort()
10.3.59: stable_partition()
10.3.60: stable_sort()
10.3.61: swap()
10.3.62: swap_ranges()
10.3.63: transform()
10.3.64: unique()
10.3.65: unique_copy()
10.3.66: upper_bound()
10.3.67: Heap algorithms
10.3.67.1: make_heap()
10.3.67.2: pop_heap()
10.3.67.3: push_heap()
10.3.67.4: sort_heap()
10.3.67.5: A small example using the heap algorithms
Chapter 11: The IO-stream Library
11.1: Streams: insertion (<<) and extraction (>>)
11.1.1: The insertion operator <<
11.1.2: The extraction operator >>
11.2: Four standard iostreams
11.3: Files and Strings in general
11.3.1: String stream objects: a summary
11.3.2: Writing streams
11.3.3: Reading streams
11.3.4: Reading and writing streams
11.3.5: Special functions
11.3.6: Good, bad, and ...: IOStream Condition States
11.3.7: Formatting
11.3.7.1: The (v)form() and (v)scan() members
11.3.7.2: Manipulators: dec, hex, oct and other manipulators
11.3.7.3: Setting the precision: the member precision()
11.3.7.4: (Un)Setting display flags: the member (un)setf()
11.3.8: Constructing manipulators
Chapter 12: Exceptions
12.1: Using exceptions: an outline
12.2: An example using exceptions
12.2.1: No exceptions: the setjmp() and longjmp() approach
12.2.2: Exceptions: the preferred alternative
12.3: Throwing exceptions
12.3.1: The empty throw statement
12.4: The try block
12.5: Catching exceptions
12.5.1: The default catcher
12.6: Declaring exception throwers
Chapter 13: More about friends
13.1: Inserting String objects into streams
13.2: An initial solution
13.3: Friend-functions
13.3.1: Preventing the friend-keyword
13.4: Friend classes
Chapter 14: Inheritance
14.1: Related types
14.2: The constructor of a derived class
14.3: The destructor of a derived class
14.4: Redefining member functions
14.5: Multiple inheritance
14.6: Conversions between base classes and derived classes
14.6.1: Conversions in object assignments
14.6.2: Conversions in pointer assignments
14.7: Storing base class pointers
Chapter 15: Polymorphism, late binding and virtual functions
15.1: Virtual functions
15.1.1: Polymorphism in program development
15.1.2: How polymorphism is implemented
15.2: Pure virtual functions
15.3: Comparing only Persons
15.4: Virtual destructors
15.5: Virtual functions in multiple inheritance
15.5.1: Ambiguity in multiple inheritance
15.5.2: Virtual base classes
15.5.3: When virtual derivation is not appropriate
15.6: Run-Time Type identification
15.6.1: The dynamic_cast operator
15.6.2: The typeid operator
Chapter 16: Templates
16.1: Template functions
16.1.1: Template function definitions
16.1.1.1: The keyword 'typename'
16.1.2: Instantiations of template functions
16.1.3: Argument deduction
16.1.3.1: Lvalue transformations
16.1.3.2: Qualification conversions
16.1.3.3: Conversion to a base class
16.1.3.4: Summary: the template argument deduction algorithm
16.1.4: Explicit arguments
16.1.4.1: Template explicit instantiation declarations
16.1.5: Template explicit specialization
16.1.6: Overloading template functions
16.1.7: Selecting an overloaded (template) function
16.1.8: Name resolution within template functions
16.2: Template classes
16.2.1: Template class definitions
16.2.2: Template class instantiations
16.2.3: Nontype parameters
16.2.4: Template class member functions
16.2.5: Template classes and friend declarations
16.2.5.1: Nontemplate friends
16.2.5.2: Bound friends
16.2.5.3: Unbound friends
16.2.6: Template classes and static data
16.2.7: Derived Template Classes
16.2.8: Nesting and template classes
16.2.9: Template members
16.2.10: Template class specializations
16.2.11: Template class partial specializations
16.2.12: Name resolution within template classes
16.3: An example: the implementation of the bvector template
16.3.1: The reverse_iter template class
16.3.2: The final implementation
Chapter 17: Concrete examples of C++
17.1: Storing objects: Storable and Storage
17.1.1: The global setup
17.1.1.1: Interface functions of the class Storage
17.1.1.2: To copy or not to copy?
17.1.1.3: Who makes the copy?
17.1.2: The class Storable
17.1.2.1: Converting an existing class to a Storable
17.1.3: The class Storage
17.2: A binary tree
17.2.1: The Node class
17.2.2: The Tree class
17.2.2.1: Constructing a tree
17.2.2.2: The `standard' functions
17.2.2.3: Adding an object to the tree
17.2.2.4: Scanning the tree
17.2.2.5: The primitive operations copy() and destroy()
17.2.3: Using Tree and Node
17.3: Classes to process program options
17.3.1: Functionality of the class Configuration
17.3.1.1: The interface of the class Configuration
17.3.1.2: An example of a program using the class Configuration
17.3.2: Implementation of the class Configuration
17.3.2.1: The constructor
17.3.2.2: loadResourceFile()
17.3.2.3: loadCommandLineOptions()
17.3.3: The class Option
17.3.3.1: The interface of the class Option
17.3.3.2: The static member nextOptionDefinition
17.3.4: Derived from Option: The class TextOption
17.3.4.1: The interface of the class TextOption
17.3.4.2: The implementation of the assign() function
17.3.5: The class Object
17.3.6: The class Hashtable
17.3.6.1: The Hashtable constructor
17.3.6.2: The function mayInsert()
17.3.6.3: The function expanded()
17.3.7: Auxiliary classes
17.3.7.1: The class Mem
17.3.7.2: The class String
17.3.7.3: The class StringTokenizer
17.3.7.4: The class Ustream
17.3.7.5: The class Util
17.4: Using Bison and Flex
17.4.1: Using Flex++ to create a scanner
17.4.1.1: The flex++ specification file
17.4.1.2: The derived class: Scanner
17.4.1.3: The main() function
17.4.1.4: Building the scanner-program
17.4.2: Using both bison++ and flex++
17.4.2.1: The bison++ specification file
17.4.2.2: The bison++ token section
17.4.2.3: The bison++ grammar rules
17.4.2.4: The flex++ specification file
17.4.2.5: The generation of the code