i just started programming in c++ this concept of static variable/function wasn\'t clear to me..why is this used and is there any other alternative of this!!!
static can be a little confusing because of its slightly different meaning depending upon where it is used.
A static variable, declared globally, will only be visible in that source file.
A static variable, declared locally, will keep its value over successive calls to that function (as in netrom's example)
A static member variable does not belong to the class.
A static function, declared in a class, can be used without declaring an instance of that class.