在下面C++代码中,由于删除了变量 ptr,因此 ptr 所对应的数据也随之删除,故执行下述代码时,将报错。
ptr
int* ptr = new int(10); cout << *ptr << endl; delete ptr; cout << ptr << endl;
正确 √
错误 ×