Self-Review Exercises

  1. 21.1 Fill in the blanks in each of the following:

    1. Header       must be included for class string.

    2. Class string belongs to the       namespace.

    3. Function       deletes characters from a string.

    4. Function       finds the first occurrence of one of several characters from a string.

  2. 21.2 State which of the following statements are true and which are false. If a statement is false, explain why.

    1. Concatenation of string objects can be performed with the addition assignment operator, +=.

    2. Characters within a string begin at index 0.

    3. The assignment operator, =, copies a string.

    4. A pointer-based string is a string object.

  3. 21.3 Find the error(s) in each of the following, and explain how to correct it (them):

    1. string string1{28}; // construct string1

      string string2{'z'}; // construct string2

    2. // assume std namespace is known

      const char* ptr{name.data()}; // name is "joe bob"

      ptr[3] = '-';

      cout << ptr << endl;

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset