开发者

Is there a difference between a global and a static global?

In Objective C (if that matters) is there a difference between these two state开发者_如何学JAVAments? And if so, what?

Statement 1:

std::map<id, id> foo;

Statement 2:

static std::map<id, id> sFoo;

Note that these are both globals that would be declared in the .mm at file scope.


static, in this context, means that the variable is visible only within the current file, but is visible everywhere in that file. So no: a true global variable would be visible everywhere.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜