Quiz · Memory and Smart Pointers · lesson 2 of 12
Quiz — using an object after delete
What happens when this program runs?
#include <iostream>
int main() {
int* p = new int{42};
int* q = p;
delete q;
std::cout << *p << '\n';
}What happens when this program runs?
#include <iostream>
int main() {
int* p = new int{42};
int* q = p;
delete q;
std::cout << *p << '\n';
}