Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models
diff options
context:
space:
mode:
2 files changed, 10 insertions, 10 deletions
-rw-r--r--src/Models/Table.cpp18
-rw-r--r--src/Models/Table.h2
diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp
index dd82b30..6ba20a4 100644
--- a/src/Models/Table.cpp
+++ b/src/Models/Table.cpp
@@ -100,23 +100,23 @@ void Table::readFromFile(std::ifstream& inFile) {
throw std::logic_error(fileLocationExceptionMsg("Error: Could not determine type of value at row ", cells.get_count(), inFile.tellg() % cells.get_count() + 1));
}
}
-
+#include <iostream>
Table::Table(const char* filePath) {
std::ifstream inFile(filePath);
+ std::cout << filePath << std::endl;
if (inFile.is_open())
- throw std::logic_error("Could now open file!");
+ throw std::logic_error("Could not open file!");
cells = List<List<Cell*>>();
readFromFile(inFile);
inFile.close();
}
-Table::Table(unsigned rows, unsigned cols) {
- if (rows == 0 || cols == 0)
- return;
-
- cells = List<List<Cell*>>(rows);
- for (unsigned i = 0; i < rows; i++)
- cells[i] = List<Cell*>(cols);
+Table::~Table() {
+ for (unsigned i = 0; i < cells.get_length(); i++) {
+ for (unsigned j = 0; j < cells.get_length(); j++) {
+ delete cells[i][j];
+ }
+ }
}
unsigned Table::get_rows() const {
diff --git a/src/Models/Table.h b/src/Models/Table.h
index eb62e2c..fb778e3 100644
--- a/src/Models/Table.h
+++ b/src/Models/Table.h
@@ -11,7 +11,7 @@ class Table {
public:
Table(const char* filePath);
- Table(unsigned rows, unsigned cols);
+ ~Table();
unsigned get_rows() const;
unsigned get_cols() const;