Skip to content

Commit

Permalink
creational patterns slides
Browse files Browse the repository at this point in the history
  • Loading branch information
HendEmad committed Aug 23, 2024
1 parent bd6b6e8 commit c424135
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\Program Files\\CodeBlocks\\MinGW\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}
Binary file modified Creational/Creational Design Patterns.pdf
Binary file not shown.
28 changes: 28 additions & 0 deletions slides.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <iostream>
#include <string>

class ConfigurationManager {
private:
static ConfigurationManager* instance;
ConfigurationManager() {
std::cout << "Loading configuration from file...\n";
}
public:
static ConfigurationManager* getInstance() {
if(instance == nullptr)
instance = new ConfigurationManager();
return instance;
}
std::string getConfigValue(const std::string& key) {
return "Value for " + key;
}
};

ConfigurationManager* ConfigurationManager::instance = nullptr;
int main() {
ConfigurationManager* config1 = ConfigurationManager::getInstance();
ConfigurationManager* config2 = ConfigurationManager::getInstance();

std::cout << config1->getConfigValue("Setting 1") << std::endl;
std::cout << config2->getConfigValue("Setting 2") << std::endl;
}
Binary file added slides.exe
Binary file not shown.

0 comments on commit c424135

Please sign in to comment.