diff --git a/.editorconfig b/.editorconfig index dde7877..b11bce6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,3 +10,7 @@ trim_trailing_whitespace = true [{*.js,*.mjs,*.ts,*.json,*.yml}] indent_size = 2 indent_style = space + +[*.cpp] +indent_size = 2 +indent_style = space diff --git a/C++/2-list.cpp b/C++/2-list.cpp index 86509b7..21f29c4 100644 --- a/C++/2-list.cpp +++ b/C++/2-list.cpp @@ -13,7 +13,7 @@ class List { ListItem* head; ListItem* tail; public: - List() { + List() { head = NULL; tail = NULL; }; @@ -37,6 +37,14 @@ class List { current = current->next; } } + + ~List() { + while (head) { + ListItem *current = head; + head = head->next; + delete current; + } + } }; int main() {