error C2511

Started by
2 comments, last by firstelder_d 16 years, 5 months ago
I am getting the following error: error C2511: 'addResource' : overloaded member function 'int (class SE::Resource *)' not found in 'SE::Engine' from the following code: engine.h

class Resource;

class Engine
{
  ...

  int addResource(Resource *res);

  ...
};

engine.cpp

#include "engine.h"
#include "resource.h"

...

int Engine::addResource(Resource *res)
{
  ...
}

so obviously the function should be found, because its there. The function shows up in the list after typing Engine:: If I change 'class Resource' to '#include "resource.h"' this error goes away but then I have the cyclic dependent header file problem. I'm thinking its some header file thing I not aware of.
Advertisement
Try removing #include "resource.h" from engine.cpp and putting it into engine.h instead
How did you put the SE namespace in the header and .cpp files?

It should be like this:

engine.h:
namespace SE{  class Resource;  class Engine  {    ...    int addResource(Resource *res);    ...  };};


engine.cpp:
#include "engine.h"#include "resource.h"namespace SE{...int Engine::addResource(Resource *res){  ...}};


If all else fails set the namespace manually:

int Engine::addResource( SE::Resource* res )


Edit: FFing source tags, there needs to be a standard.

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Thanks Endurion thats what the problem was 'class Resource;' was outside SE

This topic is closed to new replies.

Advertisement