本文介绍了静态函数/变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚开始编程在c ++这个静态变量/函数的概念不清楚我是什么,这是使用,是有任何其他替代这个!!!
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可能有点混乱,因为它根据使用的位置而略有不同。
static can be a little confusing because of its slightly different meaning depending upon where it is used.
在本地声明的静态变量将通过对该函数的连续调用保持其值(如netrom的示例)
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.
这篇关于静态函数/变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!