Search:
Forum
General C++ Programming
Namespaces in large programs
Namespaces in large programs
May 8, 2017 at 3:54am UTC
jgreninger
(7)
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 UTC
TheIdeasMan
(6817)
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 UTC
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs