I have a class definition with a virtual method.
On compiling I get the error that 'MethodType Class::Method' is not a static member of class Class
The most popular solution I have found is to add the keyword static to the Method definition in the header file.
However, the method is defined as virtual. So to add the static keyword I will have to remove the virtual keyword. Unfortunately that cannot be done as the class inherits from a parent where this method is also declared virtual, leading to another compiler error. (Please note, I’m using defined interfaces and have no access to the parent class’s source code)
Does anyone have any ideas?
Header file:
class X : public OtherClass
{
public:
X();
~X();
virtual structType MethodName(ParamType1,ParamType2);
};
Then in the CPP file I have:
structType * X::MethodName(ParamType1 P1, ParamType2 P2)
{
//Implementation here
}
And that gets flagged with error:
'structType* X::MethodName' is not a static member of 'class X'
Figured it out.
Finally. In the implementation of MethodName1
ParamType1 was a non-standard type. It is actually a class in the underlying application
to which I have only the API.
Turns out that the implemtation for class ParamType1 was missing / not compiled / something.
The problem with linking was not to do with the class I loaded, even though it would appear as such because of the line the compiler provided.
So for future reference, when using classes and struct in a function definition, keep an eye out for this linking error.
Thanks for the assist again everyone.