Separate names with a comma.
Discussion in 'Mac Programming' started by Sunil, Feb 24, 2007.
why static functions can access static variables only
this is really one of the shortest threads I've seen on MR and I'm not even certain it's a question or a statement... ... if you were a little bit less vague we could actually help you, if you want...
Because a static method will more than likely come into existance LONG before the non-static variable will.
You can only access the non-static variables of a class if you have a pointer to a particular instance of the class.
Non-static functions of a class are always associated with a particular instance of a class and have the 'this' pointer initialised to point to the object in memory. Static functions on the other hand are not associated with any particular instance of the class and so do not have a 'this' pointer.
Sorry, that was a really bad explanation but I hope it helps a bit.
b e n