c++ - const定义疑惑

标签 c++

将某物定义为有什么不同吗

const string msg=_T("serious");
const string& msg=_T("serious");

string const msg=_T("serious");
string const&msg=_T("serious");

谢谢

最佳答案

两者没有区别是一样的。这只是不同的说法。

关于c++ - const定义疑惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7039266/

相关文章:

c++ - 使用不同类型的元素构造 vector 拷贝时如何显式转换?

c++ - 如何更改 C++ 对象的类(实现可变类型)

c++ - 无法设置PowerPC交叉编译器工具链?

c++ - 大整数加法,我知道这个理论......在实践中仍然生锈

c++ - 在不破坏现有代码的情况下添加新的枚举

c++ - 枚举语法错误 :missing tag name and constant

c++ - 将除最后一个以外的所有可变参数模板参数解压为变量类型

c++ - 为什么我们必须在复制构造函数的参数中使用引用而不是指针?

c++ - 工厂模式 : What to do when factory class is too big?

c++ - Qt 中默认不关联 NULL 的指针