Are static class variables the same as extern variables, only with class scope?

匆匆过客 提交于 2019-12-04 05:58:04

Yes, both have static storage duration and external linkage; they have essentially the same run-time properties, only differing in (compile-time) visiblity.

More or less. Both have external linkage, and static lifetimes. Both will be initialized on program start-up, and destructed on exit.

Yes.

As an additional info, in some programming languages that use non optional namespaces / modules, static class variables can be exchanged with global variables.

In some cases, those other programming variables, doesn't even have static class variables, and you may use global variables, instead.

Some developers prefer use static class variables, enforcing its relation with the class.

Its also a matter of how are you designing your application, even if both features are available.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!