In C++, when we assign an object as null, can we still use that object to call it's member functions? My understanding was when we assign object as null, then no memory gets created so we shouldn't be able to assign it's data member values or call functions until we assign memory using new operator. I was expecting it to throw me a compiler error, but below program is working fine. Why is that? Can someone please explain.
class A{
public:
void print(){
std::cout<<"hi\n";
}
};
int main()
{
A *a = NULL;
//or A *a = nullptr;
//or A *a;
a->print();
}