From 40d25c43f45a16569768deddffc9e2935e931968 Mon Sep 17 00:00:00 2001 From: thesmallrock Date: Tue, 6 Jun 2023 05:32:02 -0300 Subject: [PATCH] Fixing "new and delete operators" titles. (#3994) --- .../raw-pointers/100-new-delete-operators.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/data/roadmaps/cpp/content/105-pointers-and-references/raw-pointers/100-new-delete-operators.md b/src/data/roadmaps/cpp/content/105-pointers-and-references/raw-pointers/100-new-delete-operators.md index 03b719c91..d810f0f0c 100644 --- a/src/data/roadmaps/cpp/content/105-pointers-and-references/raw-pointers/100-new-delete-operators.md +++ b/src/data/roadmaps/cpp/content/105-pointers-and-references/raw-pointers/100-new-delete-operators.md @@ -2,7 +2,7 @@ Raw pointers in C++ are low-level constructs that directly hold a memory address. They can be used for manually allocating memory, creating dynamic arrays, and passing values efficiently, among other things. -##`new` Operator +## `new` Operator The `new` operator is used to allocate memory on the heap. The memory allocated using `new` remains available until you explicitly deallocate it using the corresponding `delete` operator. @@ -13,7 +13,7 @@ int* ptr = new int; // Dynamically allocates an int on the heap *ptr = 42; // Assigns the value 42 to the allocated int ``` -##`delete` Operator +## `delete` Operator The `delete` operator is used to deallocate memory that has been allocated using `new`. After memory is deallocated, it's available to be reallocated for other purposes. Failing to properly deallocate memory can lead to memory leaks. @@ -26,7 +26,7 @@ int* ptr = new int; // Dynamically allocates an int on the heap delete ptr; // Deallocates the memory assigned to ptr ``` -##`new[]` and `delete[]` Operators +## `new[]` and `delete[]` Operators The `new[]` and `delete[]` operators are used for allocating and deallocating memory for an array of objects. The syntax for `new[]` and `delete[]` is very similar to that of `new` and `delete`. @@ -44,4 +44,4 @@ for (int i = 0; i < n; i++) { delete[] arr; // Deallocates the memory assigned to the array ``` -In summary, raw pointers, and `new` and `delete` operators allow manual memory management in C++, providing control over allocation and deallocation. Make sure to always deallocate memory allocated with `new` or `new[]`, to avoid memory leaks in your programs. \ No newline at end of file +In summary, raw pointers, and `new` and `delete` operators allow manual memory management in C++, providing control over allocation and deallocation. Make sure to always deallocate memory allocated with `new` or `new[]`, to avoid memory leaks in your programs.