Multiple Choice Quiz

1. Is the following C++ code valid and safe? Why or why not?
  const char * HelloString() {
    return "Hello";
  }

2. Which of the following is a valid reason that you should avoid using namespace std; in your code?

3. What can the keyword mutable be used for in C++?

4. You should use an std::array from the C++ standard library (e.g., std::array<int, 10> my_array rather than a C-style array (e.g., int my_array[10]). Which of the following is NOT a reason why?

5. What order are a class' member variables initialized in?

6. How do you speed up your compilation using CPU architecture-specific optimizations?

7. What functionality is NOT provided by Doxygen?

8. If two variables are defined as const int * x and int * const y, what is the difference in their types?

9. What is the advantage of using std::make_unique or std::make_shared over constructing your unique/shared pointers directly?

10. Which of the following is a good reason to use std::unique_ptr instead of a raw pointer?


Click Check Answers to identify any errors and try again. Click Show Answers if you also want to know which answer is the correct one.