Structuring a C ++ application (directory and folders)

I come from web development, and I need to ask C ++ programmers how they manage their directory for a model-based project?

I designed my project in Visual Studio C ++ Solution Manager as follows:

-> Header Files
   --> Models
       DatabaseEngine.interface.h

-> Resources

-> Source Files
   --> Models
       DatabaseEngine.cpp
   --> Application
       Core.cpp
       Bootstrap.cpp
   --> FrontController
       ---

I made an exact duplicate of the Model directory in the Headers directory and added them with a name ".interface", since they are interfaces, and their real implementation lies in the mirror path under Sources.

And I have custom types such as DBConnectionwhich I don’t know where to put them? Should I put them in a file with a name CustomTypes.cppor should I link them to their associated parent model / class / object?

I am concerned about agreement and standards.

+4
1

, ++ - , ; )

, , , , , .

/ProjectName
    /src
        /libs <- Libraries go here
            /Models <- Assuming you want to make a library out of your models
                User.h
                User.cpp
                ... <- Putting header and implementations together is not a problem,
                       they should be edited in parallel oftentimes
                /Utilities <- Should your library grow, you can make it more modular
                              by creating subdirectories
                              (that could contain subdirectories, etc.)
                    DBConnection.h
                    DBConnection.cpp

        /apps <- define your applications here.
                 They probably rely on classes and functions defined in one or several of your libaries define above.
            /ApplicationA
                Core.h
                Core.cpp
                Bootstrap.h
                Bootstrap.cpp
    /resources
    /doc

    # Below are 'environment specific' folders.
    /vs <- Visual studio project files
    /xcode <- Xcode project files

  • (.h, .hpp ) , (.cpp). , ( ). .interface, , IDE ( ), .
  • ( ), : .
    • , (, ), ( ) .

++ . /. DBConnection.h DBConnection, ( ) DBConnection.cpp.

Personnaly, , - , . , , .

, , . , , .

, . IDE .

CMake, . CMakeLists.txt ( ProjectName/), add_subdirectory(src), , CMakeLists.txt ProjectName/src/ ..

+5

All Articles