I typically make a Types.h to define all of my types in and then include that in all of my project files. I haven't ever seen this anywhere though, so I assume it is "bad/wrong". The situation is often like this:
Consider a class Gardener that needs to know type of grass he will be cutting. Then consider a class Lawnmower that also needs to know what type of grass will be cut. What I would have done in the past is put typedef float GrassType;
in Types.h and then included Types.h from Gardener.h and Lawnmower.h.
If, instead, I put the typedef in Gardener.h, then to access it from Lawnmower.h I would have to include Gardener.h, but since Gardener.h includes Lawnmower.h (so he can know what kind of lawnmower he has), that makes a circular dependency.
Is there a better way to do this than to introduce a template parameter to Lawnmower that can be set by the Gardener that owns it?
Thanks,
David