From 91a4c49fc4a58ee5256b7e54a68ac7333dd520bc Mon Sep 17 00:00:00 2001 From: Heidy Gallardo Date: Sat, 14 Jun 2025 16:42:32 -0500 Subject: [PATCH 01/10] setup file path --- .../cpp/concepts/pointers/terms/get/get.md | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 content/cpp/concepts/pointers/terms/get/get.md diff --git a/content/cpp/concepts/pointers/terms/get/get.md b/content/cpp/concepts/pointers/terms/get/get.md new file mode 100644 index 00000000000..562ed1c8d9c --- /dev/null +++ b/content/cpp/concepts/pointers/terms/get/get.md @@ -0,0 +1,44 @@ +--- +Title: '.get()' +Description: 'A brief description.' # Required; ideally under 150 characters and starts with a present-tense verb (used in search engine results and content previews) +Subjects: # Please only use Subjects in the subjects.md file (https://github.com/Codecademy/docs/blob/main/documentation/subjects.md). If that list feels insufficient, feel free to create a new Subject and add it to subjects.md in your PR! + - 'A subject name' + - 'A second subject name' + - 'An nth subject name' +Tags: # Please only use Tags in the tags.md file (https://github.com/Codecademy/docs/blob/main/documentation/tags.md). If that list feels insufficient, feel free to create a new Tag and add it to tags.md in your PR! + - 'A tag' + - 'A second tag' + - 'An nth tag' +CatalogContent: # Please use course/path landing page slugs, rather than linking to individual content items. If listing multiple items, please put the most relevant one first + - 'learn-example-course' + - 'paths/example-path' +--- + +[A brief definition - make sure first mention of term is in **bold**.] + +## Syntax + +[Text, code, images, parameters, etc. about the syntax] + +## Example + +[Text, code, images, etc. about example 1] + +## Codebyte Example (if applicable) + +We can currently support: + +- Python +- JavaScript +- Ruby +- C++ +- C# +- Go +- PHP + +See [content-standards.md](https://github.com/Codecademy/docs/blob/main/documentation/content-standards.md) for more details! + +```codebyte/js +# Example runnable code block. +console.log('Hello, World!'); +``` \ No newline at end of file From 940f88ef2e5eb6a2f4c8d79408b48db377ed6397 Mon Sep 17 00:00:00 2001 From: Heidy Gallardo Date: Sat, 14 Jun 2025 17:45:07 -0500 Subject: [PATCH 02/10] added title, subjects, tags, catalogcontent --- .../cpp/concepts/pointers/terms/get/get.md | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/content/cpp/concepts/pointers/terms/get/get.md b/content/cpp/concepts/pointers/terms/get/get.md index 562ed1c8d9c..c1088f656c1 100644 --- a/content/cpp/concepts/pointers/terms/get/get.md +++ b/content/cpp/concepts/pointers/terms/get/get.md @@ -1,17 +1,16 @@ --- Title: '.get()' -Description: 'A brief description.' # Required; ideally under 150 characters and starts with a present-tense verb (used in search engine results and content previews) -Subjects: # Please only use Subjects in the subjects.md file (https://github.com/Codecademy/docs/blob/main/documentation/subjects.md). If that list feels insufficient, feel free to create a new Subject and add it to subjects.md in your PR! - - 'A subject name' - - 'A second subject name' - - 'An nth subject name' -Tags: # Please only use Tags in the tags.md file (https://github.com/Codecademy/docs/blob/main/documentation/tags.md). If that list feels insufficient, feel free to create a new Tag and add it to tags.md in your PR! - - 'A tag' - - 'A second tag' - - 'An nth tag' -CatalogContent: # Please use course/path landing page slugs, rather than linking to individual content items. If listing multiple items, please put the most relevant one first - - 'learn-example-course' - - 'paths/example-path' +Description: '' # Required; ideally under 150 characters and starts with a present-tense verb (used in search engine results and content previews) +Subjects: + - 'Computer Science' + +Tags: + - 'Pointers' + - 'Memory' + +CatalogContent: + - 'learn-c-plus-plus' + - 'paths/computer-science' --- [A brief definition - make sure first mention of term is in **bold**.] From b7bda2081450c84bbd72e8e27202491134b99269 Mon Sep 17 00:00:00 2001 From: Heidy Gallardo Date: Sat, 14 Jun 2025 19:47:27 -0500 Subject: [PATCH 03/10] added description --- content/cpp/concepts/pointers/terms/get/get.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/cpp/concepts/pointers/terms/get/get.md b/content/cpp/concepts/pointers/terms/get/get.md index c1088f656c1..6449a2b8b7d 100644 --- a/content/cpp/concepts/pointers/terms/get/get.md +++ b/content/cpp/concepts/pointers/terms/get/get.md @@ -1,6 +1,6 @@ --- Title: '.get()' -Description: '' # Required; ideally under 150 characters and starts with a present-tense verb (used in search engine results and content previews) +Description: 'Returns raw pointer to managed object without transferring ownership.' # Required; ideally under 150 characters and starts with a present-tense verb (used in search engine results and content previews) Subjects: - 'Computer Science' From 22b1b8f61a9dca8b25c689849b99841595f6a13f Mon Sep 17 00:00:00 2001 From: Heidy Gallardo Date: Sat, 14 Jun 2025 20:14:01 -0500 Subject: [PATCH 04/10] added syntax pseudoblock --- content/cpp/concepts/pointers/terms/get/get.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/content/cpp/concepts/pointers/terms/get/get.md b/content/cpp/concepts/pointers/terms/get/get.md index 6449a2b8b7d..6bc174c6751 100644 --- a/content/cpp/concepts/pointers/terms/get/get.md +++ b/content/cpp/concepts/pointers/terms/get/get.md @@ -13,11 +13,14 @@ CatalogContent: - 'paths/computer-science' --- -[A brief definition - make sure first mention of term is in **bold**.] +[A brief definition - make sure first mention of term is in **bold**. ] ## Syntax [Text, code, images, parameters, etc. about the syntax] +```pseudo +T* raw_ptr = smart_ptr.get() // returns raw pointer to object managed by smart_ptr, but only smart_ptr owns it +``` ## Example From 5bfe5b9d0510931133b08ee146158aea3531a361 Mon Sep 17 00:00:00 2001 From: Heidy Gallardo Date: Sat, 14 Jun 2025 20:16:05 -0500 Subject: [PATCH 05/10] updated pseudoblock --- content/cpp/concepts/pointers/terms/get/get.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/cpp/concepts/pointers/terms/get/get.md b/content/cpp/concepts/pointers/terms/get/get.md index 6bc174c6751..2440c0a0c10 100644 --- a/content/cpp/concepts/pointers/terms/get/get.md +++ b/content/cpp/concepts/pointers/terms/get/get.md @@ -19,7 +19,7 @@ CatalogContent: [Text, code, images, parameters, etc. about the syntax] ```pseudo -T* raw_ptr = smart_ptr.get() // returns raw pointer to object managed by smart_ptr, but only smart_ptr owns it +T* raw_ptr = smart_ptr.get() // returns raw pointer to smart_ptr's managed object, but only smart_ptr owns it ``` ## Example From 549a53701f918b7a15fbc9371a5ad0a8337ca818 Mon Sep 17 00:00:00 2001 From: Heidy Gallardo Date: Sat, 14 Jun 2025 20:39:34 -0500 Subject: [PATCH 06/10] updated description --- content/cpp/concepts/pointers/terms/get/get.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/content/cpp/concepts/pointers/terms/get/get.md b/content/cpp/concepts/pointers/terms/get/get.md index 2440c0a0c10..92ba1a58343 100644 --- a/content/cpp/concepts/pointers/terms/get/get.md +++ b/content/cpp/concepts/pointers/terms/get/get.md @@ -13,13 +13,14 @@ CatalogContent: - 'paths/computer-science' --- -[A brief definition - make sure first mention of term is in **bold**. ] +The **.get()** method returns a raw pointer that points to the managed object without transferring ownership. It is used with smart pointers in C++, including the unique_ptr and shared_ptr. + +This method ensures the raw pointer is not responsible of deleting the object it is pointing to, since the smart pointer owns it. ## Syntax -[Text, code, images, parameters, etc. about the syntax] ```pseudo -T* raw_ptr = smart_ptr.get() // returns raw pointer to smart_ptr's managed object, but only smart_ptr owns it +T* raw_ptr = smart_ptr.get() // returns raw pointer to smart_ptr's managed object, but only smart_ptr has ownership ``` ## Example From 2543912a5d7af8d8973fdc78e3f8cfa00c1ccb28 Mon Sep 17 00:00:00 2001 From: Heidy Gallardo Date: Sun, 15 Jun 2025 00:51:08 -0500 Subject: [PATCH 07/10] corrected grammar --- .../cpp/concepts/pointers/terms/get/get.md | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/content/cpp/concepts/pointers/terms/get/get.md b/content/cpp/concepts/pointers/terms/get/get.md index 92ba1a58343..f69fc45a174 100644 --- a/content/cpp/concepts/pointers/terms/get/get.md +++ b/content/cpp/concepts/pointers/terms/get/get.md @@ -1,31 +1,58 @@ --- Title: '.get()' -Description: 'Returns raw pointer to managed object without transferring ownership.' # Required; ideally under 150 characters and starts with a present-tense verb (used in search engine results and content previews) +Description: 'Returns raw pointer to managed object without transferring ownership.' + Subjects: - 'Computer Science' Tags: - 'Pointers' - - 'Memory' CatalogContent: - 'learn-c-plus-plus' - 'paths/computer-science' --- -The **.get()** method returns a raw pointer that points to the managed object without transferring ownership. It is used with smart pointers in C++, including the unique_ptr and shared_ptr. +The **.get()** method returns a raw pointer that points to the managed object (if any), without transferring ownership. It is used with smart pointers in C++, including the unique_ptr and shared_ptr. -This method ensures the raw pointer is not responsible of deleting the object it is pointing to, since the smart pointer owns it. +Therefore, after using this method, the smart pointer still owns the object and is responsible for its deletion. ## Syntax ```pseudo -T* raw_ptr = smart_ptr.get() // returns raw pointer to smart_ptr's managed object, but only smart_ptr has ownership +T* raw_ptr = smart_ptr.get() // returns raw pointer to smart_ptr's managed object, but only smart_ptr owns it ``` ## Example -[Text, code, images, etc. about example 1] +This example shows how the .get() method returns a raw pointer to a managed object without transferring ownership. + +```cpp + +#include + +int main() { + + std::unique_ptr uniq_ptr(new int(20)); + + int* raw_ptr = nullptr; + + raw_ptr = uniq_ptr.get(); // returns pointer to managed object without transferring ownership + + std::cout << "value at raw_ptr address: " << *raw_ptr << std::endl; + + return 0; +} + +``` + +The output of this example is: + +```shell + +value at raw_ptr address: 20 + +``` ## Codebyte Example (if applicable) From 9a827b97e21a5cfdf8b6381f7378403f0a7f89a5 Mon Sep 17 00:00:00 2001 From: Heidy Gallardo Date: Sun, 15 Jun 2025 01:01:26 -0500 Subject: [PATCH 08/10] corrected grammar pt. 2 --- .../cpp/concepts/pointers/terms/get/get.md | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/content/cpp/concepts/pointers/terms/get/get.md b/content/cpp/concepts/pointers/terms/get/get.md index f69fc45a174..a86c537d919 100644 --- a/content/cpp/concepts/pointers/terms/get/get.md +++ b/content/cpp/concepts/pointers/terms/get/get.md @@ -1,6 +1,6 @@ --- Title: '.get()' -Description: 'Returns raw pointer to managed object without transferring ownership.' +Description: 'Returns a raw pointer to a managed object without transferring ownership.' Subjects: - 'Computer Science' @@ -13,7 +13,7 @@ CatalogContent: - 'paths/computer-science' --- -The **.get()** method returns a raw pointer that points to the managed object (if any), without transferring ownership. It is used with smart pointers in C++, including the unique_ptr and shared_ptr. +The **.get()** method returns a raw pointer that points to the managed object (if any) without transferring ownership. It is used with smart pointers in C++, including the unique_ptr and shared_ptr. Therefore, after using this method, the smart pointer still owns the object and is responsible for its deletion. @@ -37,13 +37,12 @@ int main() { int* raw_ptr = nullptr; - raw_ptr = uniq_ptr.get(); // returns pointer to managed object without transferring ownership + raw_ptr = uniq_ptr.get(); // returns pointer to a managed object without transferring ownership std::cout << "value at raw_ptr address: " << *raw_ptr << std::endl; return 0; } - ``` The output of this example is: @@ -51,12 +50,9 @@ The output of this example is: ```shell value at raw_ptr address: 20 - ``` -## Codebyte Example (if applicable) - -We can currently support: +In this example: - Python - JavaScript @@ -65,10 +61,3 @@ We can currently support: - C# - Go - PHP - -See [content-standards.md](https://github.com/Codecademy/docs/blob/main/documentation/content-standards.md) for more details! - -```codebyte/js -# Example runnable code block. -console.log('Hello, World!'); -``` \ No newline at end of file From 8d26bc40d0aa7d4ec7f1ba716744ba26a55a25ab Mon Sep 17 00:00:00 2001 From: Heidy Gallardo Date: Sun, 15 Jun 2025 01:07:52 -0500 Subject: [PATCH 09/10] added explanation for example --- content/cpp/concepts/pointers/terms/get/get.md | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/content/cpp/concepts/pointers/terms/get/get.md b/content/cpp/concepts/pointers/terms/get/get.md index a86c537d919..c01533e1aa3 100644 --- a/content/cpp/concepts/pointers/terms/get/get.md +++ b/content/cpp/concepts/pointers/terms/get/get.md @@ -15,7 +15,7 @@ CatalogContent: The **.get()** method returns a raw pointer that points to the managed object (if any) without transferring ownership. It is used with smart pointers in C++, including the unique_ptr and shared_ptr. -Therefore, after using this method, the smart pointer still owns the object and is responsible for its deletion. +After using this method, the smart pointer still owns the object and is responsible for its deletion. ## Syntax @@ -54,10 +54,5 @@ value at raw_ptr address: 20 In this example: -- Python -- JavaScript -- Ruby -- C++ -- C# -- Go -- PHP +- uniq_ptr manages an int with a value of 20. +- After calling .get(), raw_ptr now has read and write access to the int that uniq_ptr manages. \ No newline at end of file From 64aab18dd362545fae2651cbdc74901773607317 Mon Sep 17 00:00:00 2001 From: Heidy Gallardo Date: Sun, 15 Jun 2025 12:57:52 -0500 Subject: [PATCH 10/10] added example details --- content/cpp/concepts/pointers/terms/get/get.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/cpp/concepts/pointers/terms/get/get.md b/content/cpp/concepts/pointers/terms/get/get.md index c01533e1aa3..4858455a791 100644 --- a/content/cpp/concepts/pointers/terms/get/get.md +++ b/content/cpp/concepts/pointers/terms/get/get.md @@ -54,5 +54,5 @@ value at raw_ptr address: 20 In this example: -- uniq_ptr manages an int with a value of 20. +- The uniq_ptr manages an int with a value of 20. - After calling .get(), raw_ptr now has read and write access to the int that uniq_ptr manages. \ No newline at end of file