我不明白这个C++错误 - 错误 C2101:常量'&'
I do not understand this C++ error - error C2101: '&' on constant
这段代码应该与GCC一起工作-我正试图让它与Visual Studio一起工作。我不知道代码是否有问题,或者我在端口上没有做正确的事情。
1>c:somepathaaa.h(52): error C2101: '&' on constant
1> c:somepathaaa.h(52): while compiling class template member function 'const blahblah::Message something::AClass<Type>::aMethod(void) const'
1> with
1> [
1> Type=const lala::BClass&
1> ]
1> c:somepathbbb.h(79) : see reference to class template instantiation 'something:AClass<Type>' being compiled
1> with
1> [
1> Type=const lala::BClass&
1> ]
1> MyApplication.cpp
文件aaa.h:52 virtual const Type aMethod() const { return Type(); }
bbb.h:79 AClass<const BClass&> blahblahblah_;
构造T为引用类型的T()
是无效的,并且没有意义。
相关文章:
- 为什么static_assert错误:即使我传递常量"expression must have a constant value"?
- NVCC 错误:string_view.h:constexpr 函数返回是非常量
- 错误:请求从"常量字符 [5]"转换为非标量类型"字符串"
- 将错误作为从字符串常量到"char*"的已弃用转换 [-Wwrite-strings]
- 错误:constexpr 变量'struct2Var'必须由常量表达式初始化
- 如何在常量计算表达式中获取编译时错误?
- 为什么定义复制构造函数会给我错误:无法将类型 'obj&' 的非常量左值引用绑定到类型为"obj"的右值?
- C++ 中常量属性的初始化构造函数错误
- 为什么我总是收到此错误:从类型为"农场动物"的右值初始化类型的非常量引用无效|
- 为什么在第二类中使用静态常量会在第一类中给出编译器错误?
- 包含常量变量并包含在多个文件中的标头的链接错误
- C++2440错误-编译器认为字符串是常量字符
- 整体模板参数。错误:在常量表达式中使用'this'
- 常量更改而不const_cast<> 为什么没有编译器警告/错误?
- 语法错误"常量错误"
- 错误:常量类型为c++的单元化成员
- 错误:常量中的字符过多
- 错误:常量初始值设定项过多
- 缓冲区长度错误(常量字符 FAR*)
- C2059:语法错误:常量