C++ Functions Pass by Value or Reference

Опубликовано: 20 Октябрь 2024
на канале: Kenny Yip Coding
441
27

C++ Pass by Value or Pass by Reference in functions? In this video we will look at several function examples where we would want to pass parameters by value or by reference. When we pass by value, we are making a copy of the value. Generally, we want to pass by value for primitive data types because it is more performant to just make that copy because of how references are implemented. For larger data types such as strings and vectors, we want to pass by reference only if we don't want to make a copy. And if we don't want to make a copy nor modify the values, we pass by const reference.

If you need to review these topics:
Functions:    • C++ Functions  
References:    • References in C++  

C++ Playlist:
   • C++ Programming Tutorial  

Install C++ with VS Code:
   • How to set up C++ in Visual Studio Code  

Subscribe for more coding tutorials 😄!