I have a set of classes to implement and I plan to do it in the following way:
(1) A master header file (entity.h) that has all the forward declarations of these classes enclosed in a namespace i.e.:
namespace SomeNameSpace {
class A;
...
class E;
}
(2) Each of the classes then have separate header files (i.e. A.h, B.h) that defines the classes and declares all the constituent variables and methods.
(3) And finally, the .cpp's that define all the members and statics (i.e. A.cpp, B.cpp).
Now, I tried to put this scheme to work by doing #include "entity.h"
, but I am slapped with an "ambiguity" error whenever I try to use one of these classes. If I skip step (1) and simply include all the individuals header files of each class, then I don't have that problem (and that's how I've been writing code).
So anyway, is my scheme viable? Is there some way to make it work? What I really wanted is to have some sort of way to put every custom object in one namespace. I suppose I can make that work by simply putting all the class declarations into one file, but that'd make entity.h bloated.
I've searched around with keywords "forward declaration", "C++", "namespace", "one namespace", "master header", "header" and couldn't find anything that's quite relevant. Maybe what I want to do is wrong?