Reputation: 63190
I have this definition of the function in my class.
The .hpp
file:
class SomeClass
{
public:
static string DoStuff(string s);
};
The .cpp
file:
#include "header.hpp"
string SomeClass::DoStuff(string s)
{
// do something
}
Compiler says:
**error C2039: 'DoStuff' : is not a member of 'SomeClass'**
Can somebody help?
EDIT: actual offending code
header definition
class DDateTime{
public:
static string date2OracleDate(DATE Date);
}
string DDateTime::date2OracleDate(DATE Date)
{
string s;
s="TO_DATE('" + DDateTime::DateFormat("%d/%m/%Y",Date) + "','dd/MM/YYYY')";
return s;
}
Upvotes: 1
Views: 351
Reputation: 2045
Are you trying to call DoStuff from a double pointer to your instance? Example:
SomeClass **class; class->DoStuff();
If so do this:
SomeClass **class; (*class)->DoStuf();
Upvotes: 0
Reputation: 55726
Usually, .cpp
files must include the matching .h
or .hpp
file.
Is it the case here ?
You can also have namespace issue (missing namespace in .cpp
file or static method definition outside of the namespace, and so on.).
Actually, it is difficult to answer until we have the real breaking code.
Moreover, I don't know if this is sample code, but it seems you used something like using std::string
or using namespace std
in your header file.
This is a bad idea because it will polute every file in which your header is included. What If someone wants to use your header file but don't want to "use" std
because string
is the name of one of its classes ?
Upvotes: 1
Reputation: 3250
Maybe a namespace issue? You could have a SomeNamespace::SomeClass with a static member function and a ::SomeClass in the outer namespace without the static member function.
Upvotes: 0