0

I currently have a situation with circular dependencies. I have two classes, let's call them A and B:

#include <classB.h>
class A {
public:
    typedef Atype Sometype;

    MyReturnValue usefulFunction(B::Btype, ...)


};

And in class B, I have:

class B {
public:
    typedef Btype Someothertype;
};

And I need to add a method to B that takes a pointer to A::Atype, such as:

    CoolReturnValue doSomething(A::Atype *value, ...)

However, the compiler gives me an error regarding incomplete types. Is there any "easy" way to get something like this to work? Classes A and B are not simple classes. I understand that I could probably get this to work by moving B::Btype and A::Atype into namespaces, and then creating class A and class B within those namespaces; however, that type of change would involve refactoring a codebase of several hundred thousand lines, which I don't have the bandwidth for at this time.

Ken P
  • 552
  • 3
  • 11
  • I apologize. I meant circular dependencies. There are no shared inheritance issues between classes A and B. – Ken P Jan 16 '20 at 05:52
  • 2
    Does this answer your question? [Forward declaration of nested types/classes in C++](https://stackoverflow.com/questions/951234/forward-declaration-of-nested-types-classes-in-c) – druckermanly Jan 16 '20 at 05:52
  • I was afraid that was going to be the answer. Now I really want to do a "git blame" to figure out who created this mess in the first place... – Ken P Jan 16 '20 at 05:56

0 Answers0