Answers for "smart pointer c++"

C++
0

smart pointer c++

void my_func()
{
    int* valuePtr = new int(15);
    int x = 45;
    // ...
    if (x == 45)
        return;   // here we have a memory leak, valuePtr is not deleted
    // ...
    delete valuePtr;
}
 
int main()
{
}
Posted by: Guest on June-07-2021

Browse Popular Code Answers by Language