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 question is related to
c++
g++
compiler-errors
This means a class is redundantly mentioned with a class function. Try removing JSONDeserializer::
A worthy note for readability/maintainability:
You can keep the JSONDeserializer::
qualifier with the definition in your implementation file (*.cpp).
As long as your in-class declaration (as mentioned by others) does not have the qualifier, g++/gcc will play nice.
For example:
In myFile.h:
class JSONDeserializer
{
Value ParseValue(TDR type, const json_string& valueString);
};
And in myFile.cpp:
Value JSONDeserializer::ParseValue(TDR type, const json_string& valueString)
{
do_something(type, valueString);
}
When myFile.cpp implements methods from many classes, it helps to know who belongs to who, just by looking at the definition.
Are you putting this line inside the class declaration? In that case you should remove the JSONDeserializer::
.
I saw this error when my header file was missing closing brackets.
Causing this error:
// Obj.h
class Obj {
public:
Obj();
Fixing this error:
// Obj.h
class Obj {
public:
Obj();
};
Source: Stackoverflow.com