Organization of code in C ++

I just switched from java to C ++. I am a bit confused about organizing the source code.

In Java, we have packages for organizing between each module.

What are some common ways to organize C ++ source code?

+5
source share
4 answers

If you look at large open source projects in C or C ++, you will find many ways to organize the source. However, a few common scenarios are to use the directory structure module(or component) with srcand includein each module. Alternatively, you can use it the other way around and use src\moduleand include\module.

If you have test code that often goes into module\testor test\module.

++ " , ". include\public ( public\include), .

, " , ", , , - - , -, "" , - , DLL, DLL, , [ (, , ), , .

namespaces .

+2

:

, , Java. # , relative/path/from/src path.of.package.

++ : http://www.cplusplus.com/doc/tutorial/namespaces/

0

:

#include namespace , Java.

0

: / , ( ) (, ) .

, ++ - :

  • ,
  • ,
  • ,

, java, , :

  • .h/.cpp , , .
  • .

Thus, the client can write something like:

#include "groupA/subgroupB/classC.h"
using namespace groupA;
subgroupB::classC object;
0
source

All Articles