C ++中的额外限定错误 [英] extra qualification error in C++
问题描述
我有一个成员函数,定义如下:
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:
错误:额外资格'JSONDeserializer ::'在成员'ParseValue'上
error: extra qualification 'JSONDeserializer::' on member 'ParseValue'
?如何清除此错误?
推荐答案
这是因为您有以下代码:
This is because you have the following code:
class JSONDeserializer
{
Value JSONDeserializer::ParseValue(TDR type, const json_string& valueString);
};
这不是有效的C ++,但Visual Studio似乎接受它。您需要将其更改为以下代码,以便能够使用符合标准的编译器(gcc更符合此标准的标准)进行编译。
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);
};
错误来自于 JSONDeserializer :: ParseValue
是一个限定名(具有命名空间限定名的名称),并且这样的名称被禁止作为类中的方法名。
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屋!