One central header file containing namespace class declarations?
Posted on 2007-10-16
I am aware we can use forward declarations of namespaces and their contained classes as follows:
This saves us having to #include the header file that MyClass1 and MyClass2 are contained in, provided we only declare pointers to these types, not concrete objects. Anyway. Say I have a huge namespace that is widely used amongst multiple header files. Each header file uses several of the classes contained in the namespace MyNamespace. What I would like to know is if it would be considered bad form, or otherwise, to have one big header file that contains the partial declaration of *all* the classes that are contained in MyNamespace. EG
//MyNamespaceFD.h // FD: forward declaration
Then, instead of having multiple forward declarations like at the top of this question strewn all over multiple header files, I could simply say
Given, there is a chance that not every header file I add this include to will need to make use of all the forward declarations, but I feel it would make code easier to read and less clutered.