In my C ++ header files, I try to use forward declarations (MyClass; class) instead of #include the class header, as recommended by many C ++ coding standards (the Google C ++ style guide is one thing).
Unfortunately, when I enter the listings, I can no longer make a direct announcement. Like this:
class MyClass1
{
enum MyEnum1
{
Enum_A, Enum_B, Enum_C
};
};
#include "myclass1.hpp"
class MyClass1;
class MyClass2
{
MyClass1* ptr;
void func( MyClass1::MyEnum1 e );
};
The best solution I can think of is to replace the enumerations with member constants:
MyClass1
{
static const int Enum_A;
static const int Enum_B;
static const int Enum_C;
};
const int Enum_A = 1;
const int Enum_B = 2;
const int Enum_C = 3;
In this case, the solution seems worse than the problem.
I am currently reviewing a large-scale software design in C ++ (Lakos) and working effectively with legacy code (Feathers) for dependency breaking methods, but have not yet found a good solution.