Embercode
✕
Pointers and Memory AddressesQuick quiz

Memory mixed review

6 questions. Covers Aliasing.

Questions 1 to 5 of 6

  1. 1. What does this program print? ``cpp #include <cstddef> #include <iostream> struct Mix { char a; short b; char c; }; int main() { std::cout << sizeof(Mix) << ' ' << offsetof(Mix, c) << '\n'; return 0; } ``
  2. 2. What does this program print? ``cpp #include <iostream> struct Node { int value; Node* next; }; int main() { Node c{3, nullptr}; Node b{2, &c}; Node a{1, &b}; Node* head = &a; head = head->next; head->next = head->next->next; for (Node* cur = head; cur != nullptr; cur = cur->next) { std::cout << cur->value << '\n'; } std::cout << "a.next->value = " << a.next->value << '\n'; return 0; } ``
  3. 3. Match each term from the shared ownership and leaks lessons to its meaning.

    Choose the matching item for each row.

  4. 4. Match each value from the row-major, cache, stack and const lessons to what it is.

    Choose the matching item for each row.

  5. 5. A dangling pointer still holds an address that is not zero. Why can a p != nullptr check not catch a read through it?

5 question(s) left on this page.