Hide menu

C++ Primer, 5th Edition, reading instructions

Seminar 1, Basic C++

  • Chapter 1 Getting started (except 1.5—1.6)
  • Chapter 2 Variables and Basic Types (2.4.4 and 2.5.3 covered later)
  • Chapter 3 Strings, Vectors, and Arrays
  • Chapter 4 Expressions (4.8 optional)
  • Chapter 5 Statements (except 5.6, but covered later)
  • Chapter 6 Functions
  • Chapter 8 The IO Library (except some "low-level" buffer management)
  • Section 12.2 Dynamic Arrays
  • Section 17.1 The tuple type
  • Section 17.5.1 Formatted Input/Output
  • Section 17.5.2 Unformatted Input/Output Operations
  • Section 19.3 Enumerations
  • Section 19.6 union: A Space-Saving Class (only necessary to read the "Defining union" and "Using a union Type" sections)

Seminar 2, Single Class Design and Operator Overloading

  • Chapter 7 Classes (except 7.5.6 Literal Classes)
  • Chapter 13 Copy Control
  • Chapter 14 Overloaded Operations and Conversions (except 14.8, covered later)
  • Section 19.7 Local Classes

Seminar 3, Derived Classes, Polymorphism, and RTTI

  • Chapter 15 Object-Oriented Programming
  • Section 18.1 Exception Handling
  • Section 18.3 Multiple and Virtual Inheritance (optional, will be covered later)
  • Section 19.2 Run-Time Type Identification

Seminar 4—6, Templates

  • Chapter 16 Templates and Generic Programming
  • Section 18.2 Namespaces

Seminar 7—8, Standard Library

  • Chapter 9 Sequential Containers
  • Chapter 10 Generic Algorithms
  • Chapter 11 Associative Containers
  • Appendix A.1 Library Names and Headers (corresponding knowledge)
  • Appendix A.2 A Brief Tour of the Algorithms

Scattered

  • Section 19.1 Placement new Expressions
  • Section 19.4 Pointers to Class Members

Chapters and sections not covered

  • Section 12.2.2 The Allocator Class
  • Section 12.3 Using the Library: A Text-Query Program
  • Section 15.9 Text Queries Revisited
  • Section 17.2 The bitset Type
  • Section 17.3 Regular Expressions
  • Section 17.4 Random numbers
  • Section 19.8 Inherently Nonportable Features
  • Appendix A.3 Random Numbers

Comments from previous teachers

10.4.3 Reverse Iterators

What's said about how reverse iterator works are correct from a logical point of view, and that's of course the important thing. But, the details are actually a bit different, and the reason for that is there is always a pointer past the end of an array, but there might not be a valid pointer to before the beginning of an array.

rbegin() return the same iterator position as end(), i.e. past-the-end, and rend() returns the same iterator position as begin(), i.e. to the first elementet (if any). In figure 10.1, vec.crend() actually gives the same iterator value as vec.begin(), and vec.rbegin() the same as vec.end(). What makes reverse iterators work as they should, is because operator*, and operator->, for reverse iterators, adjusts the iterator position one step towards the beginning before dereferencing takes place. operator* for reverse iterators copies the iterator value, adjusts the copy one position towards the beginning, and dereferences the adjusted iterator. Corresponding for operator->, which actually should be implemented using operator*.

In the example at the top of page 408, r_iter will therefore be initialized to "past-end". The first dereferencing of r_iter will give the last element, because operator* adjusts the iterator to the last element before dereferering takes place.

Figure 10.2 and how base() works is correct in practice, but not regarding the values of the reverse iterators. crbegin() returns "past-end" (after L) and iterator rcomma will actually point to the L following the comma. The iterator that rcomma.base() returns is correct, since base() makes nu adjustment regarding the iterator position, it's just a type conversion (and rcomma is actually pointing att 'L').


Page responsible: Christoffer Holm
Last updated: 2019-09-20