[C++] Project Structure

HOME/client/vietcombank/include : contains a specific client.h
HOME/client/citibank/include : contains a specific client.h
HOME/include : contains common header files (*.h)
HOME/src : contains common sources (*.cpp)
HOME/main.cpp

1. Client’s configurations

HOME/client/vietcombank/include/client.h
  • Configurations for each clients should be put in a particular “client.h” and under a particular folder. Let’s assump, we have 2 big clients : google and facebook.
  • In this header file, we’ll define macros

2. Common header files

HOME/include/bank_domestic.h

3. Common sources

//sources
HOME/src/banking_funcs.cpp
HOME/src/banking_funcs.h
HOME/src/insurance_funcs.cpp
HOME/src/insurance_funcs.h
//services
HOME/src/service/service_banking.cpp
HOME/src/service/service_banking.h
HOME/src/service/service_insurance.cpp
HOME/src/service/service_insurance.h

3.1 Banking Functionalities

3.2 Insurance Functionalities

4. main.cpp

HOME/main.cpp

Additional Notes

Advantage of using “#ifndef, #define, #endif” in header file

  • This is called “Fileguards” as a protection to avoid cross duplidated when many sources include this .h file.

Advantage of using namespace

  • If we deploy this software to a client who is both BANKING and INSURANCE, then we’ll face a compile error “void __cdecl initialize(void)” (?initialize@@YAXXZ) already defined in banking_funcs.obj” due to name collision of func initialize().
  • We could resolve it by renaming the func, or you could use namspace concept.
  • In insurance_funcs.cpp(.h), we’ll wrap functions with namespace insurance.
  • In the cpp file, service_insurance.cpp, we’ll add “using namespace insurance;” after the include of #include “insurance_funcs.h”. In this case, after “#include “service_insurance.h””
  • Or we could preface the namespace before the API call
  • Now, let’s see the result 😋

--

--

--

“Developer never die” 😎🇻🇳

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

ODIE — Pre Assessment Prep

Git Add -P: A Scalpel for Your Commits.

Network Automation made easy, “The Why — What — How”

DevOps starts with admitting you have a problem

“Die Goldene Inge” Solidity Contract walkthrough

Google App Engine

Get Ready for iOS 14 and SKAdNetwork

CS373 Spring 2022 Week 3: Nathaniel Nemenzo

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
binh12A3

binh12A3

“Developer never die” 😎🇻🇳

More from Medium

C vs C++: Major Differences To Check In The Year 2022

Static Libraries vs Dynamic Libraries in C

What is C Programming?

What is C programming?

C Preprocessor