This repository is part of the Refactoring.Guru project.
It contains C++ examples for all classic GoF design patterns. Each pattern includes two examples:
- Conceptual examples show the internal structure of patterns with detailed comments.
- RealWorld examples show how the patterns can be used in a real-world C++ application.
The examples were written as cross platform console application using c++17. It means that you should be able to compile and execute those examples with any recent compiler.
we recommend working with Visual Studio Code because it is a lightweight and cross-platform tool .It is a very complete IDE and is available for free (https://code.visualstudio.com/). You may need to install c++ extension and the compiler you prefer (The extension is still in preview and its focus is code editing, navigation, and debugging support for C and C++). For more information on how to use VSCode with c++ refer to: https://code.visualstudio.com/docs/languages/cpp .
For code execution in VSCode you will need to set up your task first. An example using g++ :
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++ -g -std=c++17 Conceptual/main.cc -o main",
"group":{
"kind": "build",
"isDefault": true
},
"problemMatcher":"$gcc"
}
]
}
Then you just need to start the executable. In case you have some doubts here you have an useful tutorial using vscode.
I appreciate any help, whether it's a simple fix of a typo or a whole new example. Just make a fork, make your change and submit a pull request.
Here's a style guide which might help you to keep your changes consistent with the rest of the project's code:
- All code should match the Google style guide.
- Aim to put all code within one .cc file. Yes, I realize that it's not how it supposed to be done in production. However, it helps people to understand examples better, since all code fits into one screen.
- The comments doesn't follow the style guide for compatibility reasons with other language examples.
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.