Possible Duplicate:
Accessing class members on a NULL pointer
A very silly question or may be my conceptual doubt.
#include <iostream>
using namespace std;
class A
{
public:
void print()
{
cout<<"Printing\n";
}
};
int main()
{
A * a = NULL;
a->print();
return 0;
}
The output is: Printing
How is a
pointer(which is NULL) able to access member function of class A.
Please explain... may be its just a silly question but I had the impression that a NULL pointer will not access the class's member function.