feat: update

This commit is contained in:
2025-12-17 10:57:49 +03:30
parent 37ba8ab075
commit 87ed2f74d0
9 changed files with 121 additions and 12 deletions
@@ -96,8 +96,8 @@
---
## 📑 Slides & Materials
- 👨‍🏫 [Professor Slides (PDF)](4-ProfessorSlides.md)
- 🧑‍🏫 [TA Workshop Slides (PDF)](5-TASlides.md)
- 👨‍🏫 [Professor Slides (PDF)](01-topics/04-function-1/4-ProfessorSlides.md)
- 🧑‍🏫 [TA Workshop Slides (PDF)](01-topics/04-function-1/5-TASlides.md)
---
## 🛠️ Workshop & Assignments
@@ -38,8 +38,8 @@
> - Ask your TA — thats what were here for.
- [Topic Q&A](3-Q&A.md)
- [Professor Slides](4-ProfessorSlides.md)
- [TA Slides](5-TASlides.md)
- [Professor Slides](01-topics/04-function-1/4-ProfessorSlides.md)
- [TA Slides](01-topics/04-function-1/5-TASlides.md)
---
## ⚖️ Licensing & Usage
@@ -95,7 +95,7 @@
---
## 🛠️ Workshop & Assignments
- 💬 [Workshop Questions](1-Workshop.md)
- 💬 [Workshop Questions](01-topics/05-arrays/1-Workshop.md)
- 🧮 [Assignments]()
- ❓ [Q&A and Common Issues]()
@@ -106,9 +106,8 @@
---
## ⏩ Navigation
- [Previous Topic: Functions 1]()
- ➡️ [Next Topic: Functions 2]()
- ⬅️ [Previous Topic: Functions 1](01-topics/04-function-1/0-Overview.md)
- [Next Topic: Functions 2](01-topics/06-functions-2/0-Overview.md)
---
> [!tip] Tip
@@ -38,8 +38,8 @@
> - Ask your TA — thats what were here for.
- [Topic Q&A](3-Q&A.md)
- [Professor Slides](4-ProfessorSlides.md)
- [TA Slides](5-TASlides.md)
- [Professor Slides](01-topics/05-arrays/4-ProfessorSlides.md)
- [TA Slides](01-topics/05-arrays/5-TASlides.md)
---
## ⚖️ Licensing & Usage
@@ -54,7 +54,7 @@
---
## 📑 Slides & Materials
- 🧑‍🏫 [TA Workshop Slides (PDF)](5-TASlides.md)
- 🧑‍🏫 [TA Workshop Slides (PDF)](01-topics/06-functions-2/5-TASlides.md)
---
## 🛠️ Workshop & Assignments
@@ -71,6 +71,7 @@
## ⏩ Navigation
- ⬅️ [Previous : Arrays](../05-arrays/0-Overview.md)
- ➡️ [Next Topic: Pointers](../07-pointers/0-Overview.md)
---
@@ -38,7 +38,7 @@
> - Ask your TA — thats what were here for.
- [TA Slides](5-TASlides.md)
- [TA Slides](01-topics/06-functions-2/5-TASlides.md)
---
## ⚖️ Licensing & Usage
@@ -0,0 +1,92 @@
# 🧭 Topic: Pointers
> [!info] **Quick Overview :** This topic covers how memory is accessed and managed in C++, starting from memory addresses and the address-of operator (`&`), and moving to pointers as variables that store addresses. It explains dereferencing, pointer arithmetic, pointer types (including `void*` and pointer-to-pointer), and why all pointers have the same size on a given architecture. The relationship between arrays and pointers is discussed, including common pitfalls when passing arrays to functions. The overview also contrasts stack and heap memory, introduces dynamic allocation with `new` and `delete`, and highlights common pointer errors such as wild and dangling pointers, variables going out of scope, and the use of `nullptr`. Finally, it clarifies the role of `const` with pointers, compares pointers with reference variables, and explains why pointers are used in functions for efficiency, output parameters, and managing dynamic memory.
## 📌 Covered in This Topic
- **Memory addresses**
- What a memory address is and what it represents
- **The address-of operator (`&`)**
- How `&` is used to obtain a variables address
- **Pointers**
- What a pointer is
- Pointer size (independent of the pointed type)
- **Wild pointers**
- What they are and why they are dangerous
- **Raw pointers vs smart pointers (brief)**
- Why raw pointers exist
- A short mention of `unique_ptr`, `shared_ptr`, `weak_ptr`
- **Array names and pointers**
- How array names decay to pointers
- Problems when passing arrays to functions (loss of size information)
- **Dereferencing (`*`)**
- Accessing the value a pointer points to
- Using dereferencing to access array elements
- **Pointer arithmetic**
- How incrementing/decrementing pointers works
- Relation to the pointed data type
- **Size of pointers**
- Why all pointers have the same size on a given architecture
- **Pointer data types**
- Why pointers must have a data type
- How the type affects dereferencing and arithmetic
- **Void pointers (`void*`)**
- What they are
- Limitations and use cases
- **Pointer to pointer**
- Why and when double pointers are used
- **Stack vs heap**
- Why the stack is not always sufficient
- When dynamic (heap) allocation is required
- **Dynamic memory allocation**
- `new` and `delete`
- `new[]` and `delete[]`
- **Reference variables**
- What references are
- Differences between references and pointers
- **Dangling pointers**
- How dangling pointers are created
- How to avoid and handle them
- **`nullptr`**
- Why it exists
- Difference from `NULL` and `0`
- **Const and pointers**
- `const int*`
- `int* const`
- `const int* const`
- **Variables going out of scope**
- Lifetime of local variables
- Effects on pointers and references
- **Pointers and functions**
- Passing pointers to functions (input)
- Returning pointers from functions (output)
- Why pointers are used: efficiency, modification, dynamic memory, and shared data
---
## 📑 Slides & Materials
- 👨‍🏫 [Professor Slides (PDF)](01-topics/07-pointers/4-ProfessorSlides.md)
- 🧑‍🏫 [TA Workshop Slides (PDF)](01-topics/07-pointers/5-TASlides.md)
---
## 🛠️ Workshop & Assignments
- 🧮 [Assignments](2-Assignment.md)
- ❓ [Q&A and Common Issues]()
---
## 🌐 Additional Resources
---
## ⏩ Navigation
- ⬅️ [Previous : Functions 2 - Recursion](../06-functions-2/0-Overview.md)
- ➡️ [Next Topic: File & Struct](../08-file-struct/0-Overview.md)
---
> [!tip] **Tip :**
>
> If something doesnt make sense — **dont stay stuck alone**. Ask the TA to clarify it right away. Often, a quick question can save you a lot of time and frustration. Remember: if youre confused, chances are others are too.
@@ -0,0 +1,10 @@
## 🔗 Download
- [Download PDF - Lecture 07](https://drive.usercontent.google.com/u/0/uc?id=1NpWCnRqdEIZ7gSrdul7p2YoOLNZ0_cTB&export=download)
## View PDF Online
### Lecture 07
<iframe src="https://docs.google.com/gview?embedded=true&url=https://drive.usercontent.google.com/u/0/uc?id=1NpWCnRqdEIZ7gSrdul7p2YoOLNZ0_cTB&export=download" width="100%" height="700px" frameborder="0"> </iframe>
@@ -0,0 +1,7 @@
## 🔗 Download
- [Download PDF - Pointers](https://drive.usercontent.google.com/u/0/uc?id=1C7j89GnSQhdO8SiohPHVCPbe8u8_8W2b&export=download)
## View PDF Online
### Pointers
<iframe src="https://docs.google.com/gview?embedded=true&url=https://drive.usercontent.google.com/u/0/uc?id=1C7j89GnSQhdO8SiohPHVCPbe8u8_8W2b&export=download" width="100%" height="700px" frameborder="0"> </iframe>