C # / Java programmer learning C ++ again. Project file structure?

As the question says, I am a C # / Java programmer who is interested in (re) learning C ++. As you know, C # / Java has a somewhat strict project file structure (especially Java). I think this structure is very useful and wondered if it is good practice to make a similar structure in C ++, b) if so, what is the best way to configure it?

I know there are main β€œheaders” and β€œsource” folders, but is there a better way?

+3
source share
2 answers

I find the structure of java projects pretty enjoyable. I do it like this (root is the root directory)

root / include / foo / bar / baz.hpp becomes

namespace foo { namespace bar { // declare/define the stuff (classes, functions) here } } // foo::bar 

in code.

I save the source to

root / src / foo / bar / baz.cpp. If I have material that is not exposed to external influences, I put it in the detail / directory and namespace folder. I save make files to root /.

+3
source

a) (this) is a good practice to make a similar structure in C ++,

One way to find out is to download several open source projects and see their file structure.

In my experience, the build tool used really dictates the file structure. If it is a little painful for you to have many subdirectories with your build tool, then you will not have many subdirectories.

b) if so, what is the best way to configure it?

It depends on the build environment / dev. I personally use vim and tools for Linux files, so I installed it all manually. Someone using Eclipse or Visual Studio may have several wizards to work with.

+1
source

All Articles