I'm trying to generate header files of classes I'm reconstructing from what I disassembled with IDA. However I'm getting compile errors due to circular dependencies. For regular classes I solved it by declaring them in a separate file I include as a first. The thing is I cannot declare inner class without definition of an outer class which is the problem.
An example class structure:
Class A:
#include "B.h"
class A {
public:
class Nested {
public:
void foo(B::Nested &foo);
};
};
Class B:
#include "A.h"
class B {
public:
class Nested {
public:
void foo(A::Nested &foo);
};
};
You can forward declare the Nested
s in A
and B
, and define them afterward.
a.h
class A {
public:
class Nested;
};
B.h
class B {
public:
class Nested;
};
Nested.h
#include "A.h"
#include "B.h"
class A::Nested {
public:
void foo(B::Nested &foo);
};
class B::Nested {
public:
void foo(A::Nested &foo);
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With