Namespaces in large programs

May 8, 2017 at 3:54am
I'm having some issues with namespaces in large programs. My namespace looks like

namespace myspace {
class A;
class B;
class C;
class D;
}

#include A.h;
#include B.h;
#include C.h;
#include D.h;

Where any one of the classes my have templates. In the *.h and *.cpp files, do I need a

namespace myspace {} ?

What header file do I put in the classes in the namespace?

Thanks
May 8, 2017 at 4:17am
Put the entire class definition and all template code inside the namespace(in the header), then put the whole of the cpp code inside namespace as well (in the cpp file).

I wouldn't bother with forward declaring the classes.

Edit:

Make sure you have separate files for each class.
Last edited on May 8, 2017 at 4:18am
Topic archived. No new replies allowed.