I'm trying to help a coworker get something compiled - essentially, he was trying to reduce dependencies for a small executable we need to make from a larger software system.
I'm not sure I can fully explain the problem as I don't completely understand it... but I'm going to show what's going on here:
Library A: File: A.h
namespace CF {
typedef sometype B;
};
Library C: File C.h
//Forward declare Class
class CF::B;
Class D {
public:
B* UseB();
};
Library C: File C.cpp
#include "C.h"
#include "A.h"
using CF::B;
B* D::UseB()
{
return new B;
}
Sorry, I know this looks a little crazy but I have tried to simplify it from the set of files that we're actually dealing with.
We're typically getting either a multiple definition error on CF::B, or when we play with the code and change it around, sometimes in the CPP file it just doesn't recognize the type of CF::B.
I guess my first question is... can I forward declare the typedef like we've tried, or is there some other way to deal with the fact that B is a typedef in CF namespace, and we don't want it to be directly included in the C.h file?