0

I created a null pointer for my class. And tried to access class method using that pointer but the code did not crash.

What could be the reason for this? Is there any documentation available on memory management.

Below is the code i am using,

=====================================================

#include <iostream>
#include <stdio.h>

using namespace std;

class D
{
public:
    int a;
    void print()
    {
        std::cout << "New class" << endl;
    }
};

int main()
{
    D *dptr = nullptr;
    dptr->print();

    cin.get();
}

0 Answers0