A Tour of C++ Part II

A Tour of C++ Part II


Library (Chapter 8-16)

Chapter 8

  1. I saw some C++ codes which include the C library. For example, what’s the difference between including <string.h> and ? Why in C++ we would like to import rather than just use the <string.h> in C library ?

Chapter 9

  1. string_view is a very clever implementation, which makes it easy to pass substrings and improve performance.

Chapter 10

  1. In section 10.5, in the implementation of input operator, why we use is.get(c) instead of is>>c?
    Got the answer in the following text. is>>c skips whitespace by default, but is.get(c) does not.

Chapter 11

  1. For the vector implementation, what does one-past-the-last element mean? Why to points to the extra space? Shouldn’t it points to the last element?
  2. Very clever to store a smart pointer points to the object in the vector to save space.

Chapter 12

  1. Not quite understand why a list iterator is a pointer to a link.
    Why the element in a list does not know where the next element of that list is since they are linked as a linked list?

Chapter 13

  1. From the Swap function example, now I have better understanding of move and rvalue reference.
    As mentioned in the book, don’t use move() unless you can demonstrate significant and necessary performance improvement, since it’s too error-prone if used widely.

Chapter 14

  1. Surprised to know that C++ has parallel algorithms!

Chapter 15

  1. The future and promise are really helpful for programmers to code at the conceptual level of tasks. They are for returning a value from a task spawned on a separate thread.

Chapter 16

  1. Interested to know how C++ be named. The evolution of C++ is really respectable and amazing.