Skip to content
Quiz · Memory and Smart Pointers · lesson 2 of 12

Quiz — using an object after delete

What happens when this program runs?

C++
#include <iostream>

int main() {
    int* p = new int{42};
    int* q = p;
    delete q;
    std::cout << *p << '\n';
}