This content has been marked as final. Show 3 replies
964980 wrote:You read somewhere (don't know where) that non-static member variable can only be used by a non-static method. A static member variable belongs to the class, i.e. all objects of the class.
I read somewhere(don't know where) that static variable can only be used by a static method. But in the sample code below even a non-static function is able to use the static variable.
A non-static member variable belongs to a specific object of a class and therefore cannot be used in a static method, which, by definition, is not associated with any object in particular.
Edited by: baftos on May 15, 2013 5:27 AM