extra qualification error in C++(C++ 中的额外限定错误)
问题描述
我有一个成员函数,定义如下:
Value JSONDeserializer::ParseValue(TDR 类型,const json_string& valueString);当我编译源代码时,我得到:
<块引用>错误:成员 'ParseValue' 上的额外限定 'JSONDeserializer::'
这是什么?如何消除此错误?
这是因为您有以下代码:
class JSONDeserializer{值 JSONDeserializer::ParseValue(TDR 类型,const json_string& valueString);};这不是有效的 C++,但 Visual Studio 似乎接受它.您需要将其更改为以下代码,才能使用符合标准的编译器进行编译(在这一点上 gcc 更符合标准).
class JSONDeserializer{值解析值(TDR 类型,const json_string& valueString);};错误来自于JSONDeserializer::ParseValue 是一个限定名(具有命名空间限定的名称),并且这样的名称在类中被禁止作为方法名.>
I have a member function that is defined as follows:
Value JSONDeserializer::ParseValue(TDR type, const json_string& valueString);
When I compile the source, I get:
error: extra qualification 'JSONDeserializer::' on member 'ParseValue'
What is this? How do I remove this error?
This is because you have the following code:
class JSONDeserializer
{
Value JSONDeserializer::ParseValue(TDR type, const json_string& valueString);
};
This is not valid C++ but Visual Studio seems to accept it. You need to change it to the following code to be able to compile it with a standard compliant compiler (gcc is more compliant to the standard on this point).
class JSONDeserializer
{
Value ParseValue(TDR type, const json_string& valueString);
};
The error come from the fact that JSONDeserializer::ParseValue is a qualified name (a name with a namespace qualification), and such a name is forbidden as a method name in a class.
这篇关于C++ 中的额外限定错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C++ 中的额外限定错误
基础教程推荐
- 提升 ASIO 流缓冲 2021-01-01
- 将不可复制的闭包对象传递给 std::function 参数 2021-01-01
- 随机插入/删除的综合向量与链表基准 2022-01-01
- c++ STL设置差异 2022-01-01
- C++:获取传递给函数的多维数组的行大小 2021-01-01
- 与 CAS 的原子交换(使用 gcc 同步内置函数) 2022-01-01
- 如何部分禁用 cmake C/C++ 自定义编译器检查 2021-01-01
- 如何在 C++ 中正确使用命名空间? 2022-01-01
- 如何更改 SysDateTimePick32 或 CDateTimeCtrl 的背景颜色? 2022-01-01
- 为什么我们不能使用“虚拟继承"?在 COM 中? 2022-01-01
