Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- int* p = new int;
- *p = 3;
- cout << p << endl;
- cout << *p << endl;
- // 'delete' eliminates memory leaks if 'p' reinitialized
- delete p;
- p = new int(15);
- cout << p << endl;
- cout << *p << endl;
- // Eliminate 'dangling pointer'
- p = nullptr;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment