在阅读 Oliveira 和 Stewart 合着的《Writing Scientific Software》一书时,我看到了一段有趣的文章:
"Shared variables are dangerous and should be avoided in shared libraries
So if you are writing a shared or dynamically linked library, avoid
static
orsaved
local variables and avoid global variables."(page 55)
但是 static
成员函数呢?这些在共享库中是否同样危险?我也应该避免这些吗?为什么/为什么不?
最佳答案
But what about
static
member functions? Are these equally as dangerous in a shared library?
一点也不:static
成员函数不应避免:与表示共享状态的 static
变量不同,static
成员函数表示共享计算.只要这些计算是无状态,它们就一点都不危险。
关于c++ - 共享库中是否应该避免使用静态成员函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13244876/