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++ 中的额外限定错误


基础教程推荐
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 从 std::cin 读取密码 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01