Using new and delete to use heap memory - C++ Operator

C++ examples for Operator:delete

Description

Using new and delete to use heap memory

Demo Code

#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int* pInt{ new int };
    *pInt = 100;/*from  www . ja  v  a 2s .  com*/

    cout << hex << "The address at pInt is " << pInt << endl;
    cout << dec << "The value at pInt is " << *pInt << endl;

    delete pInt;
    pInt = nullptr;

    return 0;
}

Result


Related Tutorials