-
What is a C++ reference?
-
When should you use C++ references?
-
What is the difference between a pointer and a reference?
-
What is the output of the following?
#include <iostream> void modify(int& a, int& b) { a = a + b; b = a * 2; } int main() { int x = 3, y = 5; int& ref = x; modify(ref, y); ref = y; std::cout << x << " " << y << " " << ref << std::endl; return 0; } - How do you dynamically allocate and deallocate memory in C++?
-
What is wrong with the following code?
#include <iostream> using std::cout; using std::endl; int main() { double *d_array = new double[5]; for(int i = 0; i < 5; i++) { d_array[i] = i; } delete d_array; return 0; }