【发布时间】:2019-05-12 13:23:36
【问题描述】:
考虑以下一段代码,它本质上是 Meyer 单例的示例(希望如此)
static const std::string& foo() // Line 1
{
static std::string str("foo");
return str;
}
第 1 行中提到的 static 关键字没有意义吗?如果有,为什么?
【问题讨论】:
-
@Evg 第一行是函数签名。不是静态变量。
-
@Evg 垃圾值
标签: c++ c++11 visual-c++ singleton