views:

91

answers:

4

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;
}
A: 

Have you included the header file in your cpp file?

Cetra
A: 

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 ?

ereOn
Header is included in cpp. It finds the other defined functions... also static functions...
Tony
@Tony: Please post the actual breaking code as it is obvious that what you posted is not the code that actually poses you a problem.
ereOn
A: 

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.

Francesco
A: 

Are you missing

#include<string>

in your header file?

DanDan