Skip to content

Commit 9d1aed8

Browse files
authored
Fix for some styling issues in Pointers docs (#60)
As described.
2 parents 9a69ecc + fdce6c8 commit 9d1aed8

11 files changed

Lines changed: 21 additions & 24 deletions

docs/Language/C++/Addresses.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ has_children: false
1010
{{ page.title }}
1111
======================
1212

13-
{: .warning }
14-
This article is quite advanced and assumes you have an understanding of C++.
13+
{: .warning } This article is quite advanced and assumes you have an understanding of C++.
1514
If not, please refer to the [C++](/docs/Language/C++/C++.html) section of this book!
1615

1716
In C++, the ampersand (`&`) symbol is the address-of operator, used to obtain the memory address of a variable. The memory address represents the location in the computer's memory where the variable is stored.
@@ -24,6 +23,8 @@ int value = *somePtr; // Retrieves the value stored at the memory address
2423

2524
The memory address is typically represented as a hexadecimal number.
2625

26+
#### Example
27+
2728
```cpp
2829
#include <iostream>
2930

docs/Language/C++/ConstantPointerToConstant.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ has_children: false
1010
{{ page.title }}
1111
======================
1212

13-
{: .warning }
14-
This article is quite advanced and assumes you have an understanding of C++.
13+
{: .warning } This article is quite advanced and assumes you have an understanding of C++.
1514
If not, please refer to the [C++](/docs/Language/C++/C++.html) section of this book!
1615

17-
A const pointer to const in C++ is a pointer that cannot be used to modify the value it points to, and the pointer itself cannot be reassigned to point to a different memory location. This provides a high level of const-correctness and is often used to indicate that both the pointer and the pointed-to value are constant.
16+
Constant Pointers To Constants are a C++ pointer type that cannot be used to modify the value it points to, and the pointer itself cannot be reassigned to point to a different memory location. This provides a high level of const-correctness and is often used to indicate that both the pointer and the pointed-to value are constant.
1817

1918
```cpp
2019
int someVar = 69;
@@ -34,7 +33,7 @@ It offers several benefits:
3433
- When used in function parameters or class member functions, const pointers to const contribute to designing safer interfaces by indicating that the function/method will not modify the input data.
3534
- Allows the compiler to make certain optimizations based on the const-correctness, potentially leading to more efficient code.
3635

37-
#### Usage Example
36+
#### Example
3837

3938
```cpp
4039
#include <iostream>

docs/Language/C++/ConstantPointers.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ has_children: false
1010
{{ page.title }}
1111
======================
1212

13-
{: .warning }
14-
This article is quite advanced and assumes you have an understanding of C++.
13+
{: .warning } This article is quite advanced and assumes you have an understanding of C++.
1514
If not, please refer to the [C++](/docs/Language/C++/C++.html) section of this book!
1615

17-
Const Pointers are quite straightforward - as with any other standard `const` variable in C++, it's a type of pointer that cannot be reassigned to point to a different memory address. It still allows read-write access to the pointed-to variable though!
16+
Constant Pointers are quite straightforward - as with any other standard `const` variable in C++, it's a type of pointer that cannot be reassigned to point to a different memory address. It still allows read-write access to the pointed-to variable though!
1817

1918
```cpp
2019
int someVar = 69;
@@ -33,7 +32,7 @@ It offers a few benefits:
3332
- When used in function parameters or class member functions, const pointers contribute to designing safer interfaces by indicating that the function/method will not modify the pointer itself, offering const-correctness.
3433
- Allows the compiler to make certain optimizations based on const-correctness, potentially leading to more efficient code.
3534

36-
#### Example Usage
35+
#### Example
3736

3837
```cpp
3938
#include <iostream>

docs/Language/C++/Dereferencing.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ has_children: false
1010
{{ page.title }}
1111
======================
1212

13-
{: .warning }
14-
This article is quite advanced and assumes you have an understanding of C++.
13+
{: .warning } This article is quite advanced and assumes you have an understanding of C++.
1514
If not, please refer to the [C++](/docs/Language/C++/C++.html) section of this book!
1615

1716
The dereference operator (`*`) is used to access the value at the memory address stored in a pointer.

docs/Language/C++/MemberPointers.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ has_children: false
1010
{{ page.title }}
1111
======================
1212

13-
{: .warning }
14-
This article is quite advanced and assumes you have an understanding of C++.
13+
{: .warning } This article is quite advanced and assumes you have an understanding of C++.
1514
If not, please refer to the [C++](/docs/Language/C++/C++.html) section of this book!
1615

1716
Member Pointers are traditional pointers that point to class or struct members.

docs/Language/C++/MultilevelPointers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Multilevel pointers refer to pointers that point to other pointers, forming a ch
2020

2121
While these types of pointers provide flexibility, they can make code more error-prone. Keeping track of each level of indirection and managing memory properly is crucial to avoid memory leaks and undefined behavior. In addition to this, there are many complaints among developers that multilevel pointers drastically ireduce code readability.
2222

23-
#### Usage
23+
#### Multilevel Pointer Examples
2424

2525
A regular pointer is a single-level pointer, pointing directly to a variable.
2626

@@ -95,7 +95,7 @@ Multilevel pointers are also useful for handling arrays of pointers or for guard
9595
> "There are readability concerns for sure. As for it being a guard, _kind of, I guess?_ The main issue is that the API's are templated, so it is already kind of expecting to return a `float*` or `int*` or whatever, which, in my opinion is totally legit - guarding, like you said. But, if the array is an array of points to BEGIN with, you're left with the `**` nonsense."
9696
> _- [@Tom Shinton](www.tomshinton.com), Discussion about Multilevel Pointer use-cases._
9797
98-
#### Example Usage
98+
#### Example
9999

100100
```cpp
101101
#include <iostream>

docs/Language/C++/NullPointers.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ has_children: false
1010
{{ page.title }}
1111
======================
1212

13-
{: .warning }
14-
This article is quite advanced and assumes you have an understanding of C++.
13+
{: .warning } This article is quite advanced and assumes you have an understanding of C++.
1514
If not, please refer to the [C++](/docs/Language/C++/C++.html) section of this book!
1615

1716
`nullptr` is a keyword introduced in C++11 to represent a pointer that points to... well, nothing - It's a constant that can be assigned to any pointer type to indicate that the pointer is not pointing to a valid memory location. Before the introduction of `nullptr`, programmers often used the integer constant `0` or the macro `NULL` to represent a null pointer. However, using `nullptr` is preferred.
@@ -26,7 +25,7 @@ Note that a `nullptr` is not implicitly convertible to integral types, which hel
2625

2726
Checking or Guarding for invalid pointers frequently in your code is good practice, especially when writing critical programs.
2827

29-
#### Example Usage
28+
#### Example
3029

3130
```cpp
3231
class SomeClass

docs/Language/C++/PointerToConstant.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ It offers a few benefits:
3232
- When used in function parameters or class member functions, a pointer to const indicates that the function/method will not modify the input data, offering safer interfaces.
3333
- Allows the compiler to make certain optimizations based on const-correctness, potentially leading to more efficient code.
3434

35-
#### Example Usage
35+
#### Example
3636

3737
```cpp
3838
#include <iostream>

docs/Language/C++/Pointers.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ has_children: false
1212

1313
## Pointers Overview
1414

15-
{: .warning }
16-
This article is quite advanced and assumes you have an understanding of C++.
15+
{: .warning } This article is quite advanced and assumes you have an understanding of C++.
1716
If not, please refer to the [C++](/docs/Language/C++/C++.html) section of this book!
1817

1918
In C++, pointers are variables that store references to memory addresses of other variables. The data type of a pointer is the type of the variable it points to. They are powerful and performant due to their nature (as they tell the compiler where to look for data/objects in memory, rather than holding a copy of the data/object), but require careful handling to avoid issues like memory leaks and undefined behavior.
2019

2120
Imagine that pointers are like "signposts" that tell you where an object is in a box, rather than being a copy of the object - when there are several thousand objects floating around, the advantages are clear and can help to ensure operations occur on the correct object reference!
2221

23-
#### Usage Example
22+
#### Example
2423

2524
```cpp
2625
#include <iostream>

docs/Language/C++/References.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ References offer some benefits, such as:
3131
- References improve code readability by creating expressive and self-documenting code. The use of references indicates that the variable is being referenced or modified within a function.
3232
- References are commonly used in operator overloading, allowing you to define custom behaviors for operators like +, -, etc.
3333

34-
#### Example usage
34+
#### Example
3535

3636
```cpp
3737
#include <iostream>

0 commit comments

Comments
 (0)