Hello freinds , Can you please tell me why this pointer cannot be used on static member functions. "`this' is unavailable for static member functions" Regards, Faizan
Syntactically this pointer is not available in the static function because compiler does not pass the this pointer into the static functions. As an example when you call the member function mf() from the object obj of class C as follows obj.mf(); Then compiler internally does the following mf(C this); But for static function this is not the case and so its not available in the function. Now semantically the concept is static functions can be called before the creation of object and also independent of the object and so this object is not created and so its not available. I hope its clear now or else :shoot: more questions.
Thanks for the Reply, I just want to add STATIC FUNCTIONS and Members dont have Class Scope, as they have static storage . where as non static members and functions have class scope thats why "this" pointer is available to non static class members. Regards, Faizan.