From d5f28756d7dd500187ae8e82b8f7f4d0bfd156fe Mon Sep 17 00:00:00 2001 From: moskalenco_a Date: Sun, 15 Dec 2024 23:45:43 +0200 Subject: [PATCH 1/3] Add rules for C++ --- .editorconfig | 4 ++++ 1 file changed, 4 insertions(+) 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 From d95ad0639170bfc0dca3155a7e856b0d06523045 Mon Sep 17 00:00:00 2001 From: moskalenco_a Date: Sun, 15 Dec 2024 23:47:59 +0200 Subject: [PATCH 2/3] Add destructor to free memory --- C++/2-list.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/C++/2-list.cpp b/C++/2-list.cpp index 86509b7..c8c38d4 100644 --- a/C++/2-list.cpp +++ b/C++/2-list.cpp @@ -37,6 +37,14 @@ class List { current = current->next; } } + + ~List() { + while (head) { + ListItem *current = head; + head = head->next; + delete current; + } + } }; int main() { From 8c65f736367b3892f9600bdb093dec11e63c2a0c Mon Sep 17 00:00:00 2001 From: moskalenco_a Date: Sun, 15 Dec 2024 23:48:50 +0200 Subject: [PATCH 3/3] Remove warning --- C++/2-list.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C++/2-list.cpp b/C++/2-list.cpp index c8c38d4..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; }; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy