diff --git a/src/content/01-topics/04-function-1/0-Overview.md b/src/content/01-topics/04-function-1/0-Overview.md index af2a25f..0d41eb4 100644 --- a/src/content/01-topics/04-function-1/0-Overview.md +++ b/src/content/01-topics/04-function-1/0-Overview.md @@ -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 diff --git a/src/content/01-topics/04-function-1/1-Workshop.md b/src/content/01-topics/04-function-1/1-Workshop.md index 0bde968..2dde43c 100644 --- a/src/content/01-topics/04-function-1/1-Workshop.md +++ b/src/content/01-topics/04-function-1/1-Workshop.md @@ -38,8 +38,8 @@ > - Ask your TA — that’s what we’re 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 diff --git a/src/content/01-topics/05-arrays/0-Overview.md b/src/content/01-topics/05-arrays/0-Overview.md index 94124ac..4b3082e 100644 --- a/src/content/01-topics/05-arrays/0-Overview.md +++ b/src/content/01-topics/05-arrays/0-Overview.md @@ -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 diff --git a/src/content/01-topics/05-arrays/1-Workshop.md b/src/content/01-topics/05-arrays/1-Workshop.md index 0bde968..47fcbc2 100644 --- a/src/content/01-topics/05-arrays/1-Workshop.md +++ b/src/content/01-topics/05-arrays/1-Workshop.md @@ -38,8 +38,8 @@ > - Ask your TA — that’s what we’re 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 diff --git a/src/content/01-topics/06-functions-2/0-Overview.md b/src/content/01-topics/06-functions-2/0-Overview.md index 144be43..8670064 100644 --- a/src/content/01-topics/06-functions-2/0-Overview.md +++ b/src/content/01-topics/06-functions-2/0-Overview.md @@ -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) --- diff --git a/src/content/01-topics/06-functions-2/1-Workshop.md b/src/content/01-topics/06-functions-2/1-Workshop.md index cea6e2b..d5d7cb5 100644 --- a/src/content/01-topics/06-functions-2/1-Workshop.md +++ b/src/content/01-topics/06-functions-2/1-Workshop.md @@ -38,7 +38,7 @@ > - Ask your TA — that’s what we’re here for. -- [TA Slides](5-TASlides.md) +- [TA Slides](01-topics/06-functions-2/5-TASlides.md) --- ## ⚖️ Licensing & Usage diff --git a/src/content/01-topics/07-pointers/0-Overview.md b/src/content/01-topics/07-pointers/0-Overview.md new file mode 100644 index 0000000..688eeb9 --- /dev/null +++ b/src/content/01-topics/07-pointers/0-Overview.md @@ -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 variable’s 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 doesn’t make sense — **don’t 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 you’re confused, chances are others are too. + diff --git a/src/content/01-topics/07-pointers/4-ProfessorSlides.md b/src/content/01-topics/07-pointers/4-ProfessorSlides.md new file mode 100644 index 0000000..80f4a76 --- /dev/null +++ b/src/content/01-topics/07-pointers/4-ProfessorSlides.md @@ -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 + + + + diff --git a/src/content/01-topics/07-pointers/5-TASlides.md b/src/content/01-topics/07-pointers/5-TASlides.md new file mode 100644 index 0000000..de1a361 --- /dev/null +++ b/src/content/01-topics/07-pointers/5-TASlides.md @@ -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 + + \ No newline at end of file