diff options
3 files changed, 11 insertions, 0 deletions
| -rw-r--r-- | Year 2/Structures and data algorithms/Project/exb/CityVisit.cpp (renamed from Year 2/Structures and data algorithms/Project/exb/City.cpp) | 5 | ||||
| -rw-r--r-- | Year 2/Structures and data algorithms/Project/exb/CityVisit.h | 2 | ||||
| -rw-r--r-- | Year 2/Structures and data algorithms/Project/exc/main.cpp | 4 |
diff --git a/Year 2/Structures and data algorithms/Project/exb/City.cpp b/Year 2/Structures and data algorithms/Project/exb/CityVisit.cpp index 1fb04ca..af5128d 100644 --- a/Year 2/Structures and data algorithms/Project/exb/City.cpp +++ b/Year 2/Structures and data algorithms/Project/exb/CityVisit.cpp @@ -1,5 +1,10 @@ #include "CityVisit.h" +CityVisit::~CityVisit() { + for (Landmark* l : landmarks) + delete l; +} + CityVisit::Landmark* CityVisit::find(const std::string& name) { for (Landmark* l : landmarks) { if (l->name == name) diff --git a/Year 2/Structures and data algorithms/Project/exb/CityVisit.h b/Year 2/Structures and data algorithms/Project/exb/CityVisit.h index c513542..0dbe1fa 100644 --- a/Year 2/Structures and data algorithms/Project/exb/CityVisit.h +++ b/Year 2/Structures and data algorithms/Project/exb/CityVisit.h @@ -21,6 +21,8 @@ class CityVisit { void visitTheMostInTimeRec(Landmark* currentLandmark, std::deque<Landmark*> currPath, std::deque<Landmark*> unique, int timeLeft, std::deque<Landmark*>& bestPath, unsigned& uniqueCount); public: + ~CityVisit(); + void pushLandmarks(const std::string& from, const std::string& to, unsigned time); void parse(std::ifstream& inFile); diff --git a/Year 2/Structures and data algorithms/Project/exc/main.cpp b/Year 2/Structures and data algorithms/Project/exc/main.cpp index 95636ce..d482b7e 100644 --- a/Year 2/Structures and data algorithms/Project/exc/main.cpp +++ b/Year 2/Structures and data algorithms/Project/exc/main.cpp @@ -69,4 +69,8 @@ int main() { cb->removeUselessSubBoxes(); cb->print(std::cout) << std::endl; } + + // Free memory + for (Box* b : boxes) + delete b; } |
