From 477f73d4c483dabf6b26eb3c73456863defbfd88 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sat, 21 Oct 2023 15:47:15 +0200 Subject: [PATCH] Add unique_id for tasks --- includes/Tache.hpp | 2 ++ src/Tache.cpp | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/includes/Tache.hpp b/includes/Tache.hpp index 563ec3a..83ee72a 100644 --- a/includes/Tache.hpp +++ b/includes/Tache.hpp @@ -4,6 +4,8 @@ #include class Tache { + static int unique_id; + friend std::ostream &operator<<(std::ostream &, const Tache &); public: diff --git a/src/Tache.cpp b/src/Tache.cpp index e4f0d9c..fb2c5fe 100644 --- a/src/Tache.cpp +++ b/src/Tache.cpp @@ -1,10 +1,16 @@ #include "../includes/Tache.hpp" -Tache::Tache() { std::cout << "Hello, tache!\n"; } +int Tache::unique_id = 0; -Tache::~Tache() {} +Tache::Tache() { + ++unique_id; -Tache::Tache(const Tache &) {} + std::cout << "Hello, tache!\n"; +} + +Tache::~Tache() { --unique_id; } + +Tache::Tache(const Tache &) { ++unique_id; } const Tache &Tache::operator=(const Tache &src) { if (this == &src) {