0
#ifndef CLASSB
#define CLASSB

#include "ClassA.h"

namespace name {

class ClassB
{
public:
    static Handle conn();
};

}

#endif

-

#include "ClassB.h"

Handle name::ClassB::conn()
{
    return getHandle(ClassA::it().str());
}

-

#ifndef CLASSA
#define CLASSA

#include "ClassB.h"

namespace name {

class ClassA
{
public:
    template <typename T>
    T myFunc(const std::string&)
    {
        auto tmp = ClassB::conn();
    }
};

}
#endif

Calling ClassB::conn() gives a compiler error which says that the class ClassB is not declared. When I forward declare it I get an error message about an incomplete type.

I can't move the template function to my .cpp files as it is a template function. So, how to fix this?

user32323
  • 299
  • 1
  • 3
  • 11
  • 2
    I don't see a reason you need `#include "ClassA.h"` in your `ClassB` header file. move it to your cpp file and give it a shot? – dwcanillas Apr 08 '15 at 16:01

1 Answers1

0

Just remove #include "ClassA.h" from class B's header and it should work. But there appear to be multiple compilation problems with your code so it's hard to say (missing function getHandle, missing it(), missing type Handle etc).

Mark B
  • 95,107
  • 10
  • 109
  • 188
  • Removing the include you mentioned and adding a `#include "Configuration.h"` in the **.cpp** file of ClassB, it works. – user32323 Apr 08 '15 at 16:20