Avoiding Dangling Pointer Reference in c++




This video tutorial explains how to avoid dangling pointer reference in c++.

You will learn how to activate c++11 features in code blocks ide in the beginning of the tutorial then you are gonna learn what is dangling pointer reference, how to avoid dangling pointer reference in c++ in detail with examples.

source code for this tutorial

#include <iostream>

using namespace std;

int main()
{
    int *pointer = nullptr;

    pointer = new int;

    if(pointer != nullptr){
        *pointer = 10;
        cout << *pointer <<endl;
          delete pointer;
          pointer = nullptr;

    }else{
    cout << "memory not allocated";
    }

    return 0;
}