From 66a5cdf79a8324019d9d34055ad212ad52504e3c Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 10 May 2024 11:33:35 +0300 Subject: [w11] Fixes for destructors --- week11/Exercise02/Employee.h | 5 +++++ week11/Exercise03/Electronics.h | 4 +++- week11/Exercise04/String.h | 2 +- week11/Exercise08/Link.h | 2 +- week11/Exercise09/DirectConcat.hpp.gch | Bin 2106544 -> 0 bytes 5 files changed, 10 insertions(+), 3 deletions(-) delete mode 100644 week11/Exercise09/DirectConcat.hpp.gch (limited to 'week11') diff --git a/week11/Exercise02/Employee.h b/week11/Exercise02/Employee.h index 7be3574..086f65d 100644 --- a/week11/Exercise02/Employee.h +++ b/week11/Exercise02/Employee.h @@ -7,4 +7,9 @@ protected: char name[512]; char position[128]; char department[64]; + +public: + // Може да имаме полиморфизъм, затова се нуждаем от виртуален деструктор + // В бъдеще ще използваме = default вместо {} + virtual ~Employee() {}; }; diff --git a/week11/Exercise03/Electronics.h b/week11/Exercise03/Electronics.h index 9f3d849..7dc9b9a 100644 --- a/week11/Exercise03/Electronics.h +++ b/week11/Exercise03/Electronics.h @@ -1,10 +1,12 @@ #pragma once -class Electroics { +class Electronics { char model[256]; float needsVolts; float needsAmps; public: + virtual ~Electronics() = default; + virtual void Print(); }; diff --git a/week11/Exercise04/String.h b/week11/Exercise04/String.h index 13481a0..bf7e77a 100644 --- a/week11/Exercise04/String.h +++ b/week11/Exercise04/String.h @@ -8,7 +8,7 @@ class String { public: String(); - ~String(); + virtual ~String(); String(const String& other); String& operator=(const String& other); String(String&& other); diff --git a/week11/Exercise08/Link.h b/week11/Exercise08/Link.h index 4acb312..4ad3f6c 100644 --- a/week11/Exercise08/Link.h +++ b/week11/Exercise08/Link.h @@ -9,7 +9,7 @@ class Link : public Message { public: Link(); - virtual ~Link() override; + ~Link(); Link(const Link& other); Link& operator=(const Link& other); Link(Link&& other); diff --git a/week11/Exercise09/DirectConcat.hpp.gch b/week11/Exercise09/DirectConcat.hpp.gch deleted file mode 100644 index d7e6e3f..0000000 Binary files a/week11/Exercise09/DirectConcat.hpp.gch and /dev/null differ -- cgit v1.2.3