diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-09-20 14:45:17 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-09-20 14:45:17 +0200 |
commit | 841697f039dc5670f53ec6597ef6f639eeebcb5a (patch) | |
tree | 4a55ef53f78e90ece03d83b0cd4df73038625ded | |
parent | 65a021b35340150aa6331c4b482ebfb88446be57 (diff) |
fix memory leak
-rw-r--r-- | week-3/Persoon.cpp | 5 | ||||
-rw-r--r-- | week-3/Persoon.h | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/week-3/Persoon.cpp b/week-3/Persoon.cpp index f66e1f9..d58028c 100644 --- a/week-3/Persoon.cpp +++ b/week-3/Persoon.cpp @@ -4,7 +4,12 @@ Persoon::Persoon() { _beroep = NULL; } +Persoon::~Persoon() { + delete _beroep; +} + void Persoon::setBeroep(IBeroep* beroep) { + delete _beroep; _beroep = beroep; } diff --git a/week-3/Persoon.h b/week-3/Persoon.h index 88c742d..32ff651 100644 --- a/week-3/Persoon.h +++ b/week-3/Persoon.h @@ -11,5 +11,6 @@ class Persoon { virtual void setBeroep(IBeroep* beroep); virtual std::string getBeroep(); Persoon(); + virtual ~Persoon(); }; |