Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Incorporating a C++ namespace with header/source separation

In a project of C++ utility functions I am hand rolling for personal use, I am grouping functions for parts of the library in two files. So for a digitmanip toolset there’s I am separating the source and header code in this manner:

src/digitmanip.cpp -> include/digitmanip.hpp (functions for manipulating numbers and their digits)
src/add.cpp -> include/add.hpp (a set of adding functions for containers, varargs, etc...)

This structure I’ve used before and works well, but I would like to have all of the functions under a namespace libname. Can I keep the source/header separation the same while keeping everything under the same namespace?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Yes, C++ namespaces are additive. So you can extend any namespace in any file.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading