1. Is the following C++ code valid and safe? Why or why not? const char * HelloString() { return "Hello"; }
const char * HelloString() {
return "Hello";
}
const
"Hello"
2. Which of the following is a valid reason that you should avoid using namespace std; in your code?
using namespace std;
using
typedef
3. What can the keyword mutable be used for in C++?
mutable
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?
std::array
std::array<int, 10> my_array
int my_array[10]
.at
.back
5. What order are a class' member variables initialized in?
6. How do you speed up your compilation using CPU architecture-specific optimizations?
-march
-march=native
-Oarch
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?
const int * x
int * const y
x
y
nullptr
9. What is the advantage of using std::make_unique or std::make_shared over constructing your unique/shared pointers directly?
std::make_unique
std::make_shared
10. Which of the following is a good reason to use std::unique_ptr instead of a raw pointer?
std::unique_ptr
std::vector
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.