References in C++
References in C++ References are similar to pointers in that they directly access the memory address of an object. However, unlike with pointer syntax, we do not need to explicitly assign a reference to a memory address. Instead, we can just assign a reference to the value itself. This way, we can modify the value without having to explicitly dereference like with a pointer. The downside however is we cannot reassign a reference so once we assign a reference, it will forever refer to that memory address. Therefore, a reference is basically a const pointer without the pointer syntax. In addition, we can declare a reference to a const. This is known as const reference, however note that this refers to the value being const, not the reference itself.
C++ Playlist:
https://www.youtube.com/playlist?list=PLnKe36F30Y4ZDNIOZ51sX25pWKQ1pkpTE
Install C++ with VS Code:
https://youtu.be/DMWD7wfhgNY
Subscribe for more coding tutorials 😄!
Other Videos By Kenny Yip Coding
2024-04-17 | C++ Const Reference |
2024-04-16 | C++ Function Overloading |
2024-04-15 | C++ Functions Pass by Value or Reference |
2024-04-08 | C++ Functions |
2024-03-27 | Pointers to Pointers C++ |
2024-03-26 | C++ Dynamic Arrays vs Dynamically Allocated Arrays |
2024-03-25 | C++ Dynamic Arrays (Dynamically Allocated Array) |
2024-03-20 | Dynamic Memory Allocation in C++ |
2024-03-19 | C++ Pointers and Arrays |
2024-03-18 | C++ Null Pointers |
2024-03-14 | References in C++ |
2024-03-13 | C++ Const Pointers vs Pointer To Const |
2024-03-12 | Pointers in C++ |
2024-03-11 | Tic Tac Toe Game in C++ |
2024-03-10 | Multidimensional Arrays in C++ (2D arrays) |
2024-02-29 | Rock Paper Scissors Game in C++ |
2024-02-20 | C++ Switch Statement |
2024-02-19 | C++ Break and Continue Statements |
2024-02-14 | Do While Loops in C++ |
2024-02-12 | While Loops in C++ |
2024-02-08 | For Each Loop in C++ |