c++ - C++ 中的额外限定错误

标签 c++ g++ compiler-errors

我有一个成员函数,定义如下:

Value JSONDeserializer::ParseValue(TDR type, const json_string& valueString);

当我编译源代码时,我得到:

error: extra qualification 'JSONDeserializer::' on member 'ParseValue'

这是什么?如何消除此错误?

最佳答案

这是因为你有以下代码:

class JSONDeserializer
{
    Value JSONDeserializer::ParseValue(TDR type, const json_string& valueString);
};

这不是有效的 C++,但 Visual Studio 似乎接受它。您需要将其更改为以下代码,以便能够使用符合标准的编译器对其进行编译(在这一点上 gcc 更符合标准)。

class JSONDeserializer
{
    Value ParseValue(TDR type, const json_string& valueString);
};

错误来自 JSONDeserializer::ParseValue是一个限定名(一个有命名空间限定的名字),并且这样的名字是禁止作为类中的方法名的。

关于c++ - C++ 中的额外限定错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5642367/

相关文章:

c++ - Ubuntu : undefined reference to `al_install_system' 中的快板

找不到 Scala : value macro

compiler-errors - 注释中的代码正在编译

c++ - 在 C++ 中,如何在再次调用函数时阻止指针变为 'overridden'?

c++ - swap_if_null 的汇编代码

ubuntu - 为什么g++不能在Ubuntu中正确找到glfw3库?

python - scipy.minimize - "TypeError: numpy.float64' 对象不可调用运行”

c++ - glDrawArrays由于某些原因无法正常工作?

c++ - 为什么我的 std::vector.push_back 抛出 bad_alloc 异常

c++ - 将 C++ 类及其派生类放在特定部分