Scope New Delete

#include<iostream>
using namespace std;
int main()
{
    int *p;
    {
        int x = 7;
        p = new int(10);
        cout << "Memory Address : " << (int)p << endl;
        cout << "Value : " << *p << endl;
        cout << x << endl;
    }
    cout << endl << *p << endl;
    delete p;
    cout << "Memory Address : " << (int)p << endl;
    cout << "Value : " << *p << endl;
    return 0;
}

Comments