C++ Const Reference

Subscribers:
50,600
Published on ● Video Link: https://www.youtube.com/watch?v=aP_VwBrPrJw



Duration: 4:43
664 views
32


Const Reference in C++. In C++, there is a term called const correctness which is the practice of adding const when not modifying values. In C++, when we create temporary variables such as function parameters or the variable used for ranged base for loops, we create a copy of the value. This can be expensive for non primitive data types such as strings and vectors where we copy over every element in the collections. Therefore it is better to use a reference and if not modifying the values, a const reference. Because of how references are implemented, it is actually more efficient to just copy the primitive data types.

If you need to review these topics:
Functions: https://youtu.be/65PSQUdH5k0
Pass by Value vs Reference: https://youtu.be/77XcoXwoK2c

C++ Playlist:
https://www.youtube.com/playlist?list=PLnKe36F30Y4ZDNIOZ51sX25pWKQ1pkpTE

Install C++ with VS Code:
https://youtu.be/DMWD7wfhgNY

Subscribe for more coding tutorials 😄!







Tags:
c++ functions
C++ functions
functions c++
functions C++
functions in c++
functions in C++
c++ functions pass by value
c++ function pass by value
c++ functions pass by reference
c++ function pass by reference
pass by value c++
pass by reference c++
pass by value C++
C++ functions pass by value
C++ functions pass by reference
pass by value c++ functions
pass by reference c++ functions
pass by value C++ functions
pass by reference C++ functions