You have not instantiated an object of type Test2. There is no requirement for the compiler to generate and locate its methods. I suspect that you are thinking that the static keyword will force that. The static keyword need only force the method of access WHEN the method is ultimately generated, if ever.

You might find some compiler (particularly an older one) that will generate and locate that method, despite the fact that the object doesn't exist. That would not be a robust implementation. Your very own code would result in an item whose use would result in undefined behavior.

I haven't read the standard with regard to whether or not a compliant compiler should issue a warning or error. If you get a NULL value and are a competent programmer, you will not attempt to dereference it, right?

You may, after all, write this statement, and compile without error:
   void *myPtr = NULL;
Would you attempt to use that pointer?

Last edited by DaWei; 3May2007 at 18:55..