Hi,
I have the following piece of code.
compiled with g++.Code:#include<iostream> using namespace std; class Test { public: Test(){cout<<"Test"<<endl;} void fun() { int i=5; cout<<"fun"<<i<<endl; } }; int main() { Test *ptr = NULL; ptr->fun(); return 0; }
Executing this give output fun5.
It is correct? I have not allocated any object and so this pointer is not created.
Then how it is able to run and call the function