C++ 中的额外限定错误 [英] extra qualification error in C++

查看:15
本文介绍了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++ 中的额外限定错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆