且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

不要静态成员自己创建类(全局)对象类吗?

更新时间:2023-02-09 14:36:23

静态成员实际上只是全局变量的命名空间,是的。没有什么错误;命名空间是好的,全局是最干净的方式来完成一些任务。

Static members are effectively just namespacing for globals, yes. Nothing wrong with that; namespacing is good, and globals are the cleanest way to accomplish some tasks.

单例可以有点更有趣(按需加载...)构造(是的,你可以认为静态成员是由编译器管理的匿名单例)。

Singletons can be somewhat more interesting (load on demand...) but they're a similar construct (yeah, you could think of a static member as an anonymous singleton managed by the compiler).

像大多数东西一样,这些工具有它们的位置,只有意识形态担心他们是否适合某一特定的意识形态。

Like most things, these tools have their place, and only the ideologues worry about whether or not they "fit" with a particular ideology.