开发者

What is the use of "static" keyword with Variables, functions and objects of classes etc? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

static function/variable

Tell me the different combination of s开发者_Go百科tatic like object static and variable normal , or variable static function normal , object static function normal etc etc


A static variable and function are limited in scope they are declared in. Additionally, variables defined in functions will persist their value across function calls if defined as static.

A static method or member on an object can be used directly without a specific instance of the object, i.e. no this pointer will be automatically passed into the method. Naturally this means you can only access other static methods and variables from within a static method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜