C++ pass by VALUE vs pass by REFERENCE? 📧

  Рет қаралды 12,859

Bro Code

Bro Code

Күн бұрын

Пікірлер: 19
@BroCodez
@BroCodez 2 жыл бұрын
#include void swap(std::string &x, std::string &y); int main() { std::string x = "Kool-Aid"; std::string y = "Water"; swap(x, y); std::cout
@RandomCommentator15
@RandomCommentator15 24 күн бұрын
@@farisvaljevac1478 Yeah this function exists but he is trying to teach about reference and eventually how the built-in swap(x,y) function works under the hood to the beginners. :)
@ganapathipasupathi1666
@ganapathipasupathi1666 5 ай бұрын
many thanks sir, my many confusions are cleared. I have been watching this series from one week before, Sir did the 👏🙌good job
@Clockwerk777
@Clockwerk777 Жыл бұрын
So if i understand this correctly, is this the same concept of variable scope? where basically when you pass by value you get local versions of X and Y, which is what the function swaps, rather than the main()value?
@lastwaveundergroundsaviour7037
@lastwaveundergroundsaviour7037 2 жыл бұрын
i have been trying to do this, now i realize after watching this video that i was doing it backwards. ahaha thanks man
@FrederikWollert
@FrederikWollert 6 ай бұрын
Nice Video. But should also say that pass-by-value/reference means the same as call-by-value/reference.
@renusoni6077
@renusoni6077 5 ай бұрын
Is it a good practice to always pass variables by reference to the functions?
@shervin9561
@shervin9561 10 ай бұрын
Thanks a lot!
@adnanaman4391
@adnanaman4391 Ай бұрын
We are passing Memory Addresses from the main function to the made up Swap func through param &x&y , swapping activity done inside the swap function....then it goes on to display changed vals
@user-dy1vf7lu3i
@user-dy1vf7lu3i Жыл бұрын
1:58 Why don’t we just return X and Y? Void function don’t have return types so we change the “void” to a “string” right? Or is there no such thing as a string function?
@aliceylan1211
@aliceylan1211 Жыл бұрын
You could but the point of the video is to demonstrate the difference between passing by reference and passing by value
@ishaqmangansakan7574
@ishaqmangansakan7574 Жыл бұрын
There is a string function, but it just happens to prefer to use a void function.
@garyalvarado2155
@garyalvarado2155 3 ай бұрын
if this is the case shouldnt we always pass parameters by reference?
@kristijanlazarev
@kristijanlazarev 8 ай бұрын
I see mine are swapping even without passing by reference, why
@SafwanMashrafiSaraf-ll1wl
@SafwanMashrafiSaraf-ll1wl Ай бұрын
could you post the code here
@lastwaveundergroundsaviour7037
@lastwaveundergroundsaviour7037 2 жыл бұрын
oooo interesting
@user-lyf4isnt7daijobu
@user-lyf4isnt7daijobu 4 ай бұрын
#include void _swap(std::string x, std::string y); // passing by value // does not change value in place due to varying scopes(different memory addresses) void swap(std::string &x, std::string &y); // passing by reference // "reference" to memory address so that it changes in place int main() { std::string x = "Kool-Aid"; std::string y = "Water"; _swap(x,y); std::cout
@gamsterilyass2952
@gamsterilyass2952 4 ай бұрын
bro
@Jm2010g5
@Jm2010g5 Ай бұрын
You're the best, man Resusbcribing = in progress
C++ const parameters explained 🧱
3:08
Bro Code
Рет қаралды 7 М.
Should I pass by const reference or by value?
10:45
The Cherno
Рет қаралды 108 М.
Não sabe esconder Comida
00:20
DUDU e CAROL
Рет қаралды 58 МЛН
How Strong is Tin Foil? 💪
00:25
Brianna
Рет қаралды 42 МЛН
you will never ask about pointers again after watching this video
8:03
C++ dynamic memory explained for beginners 🧠
5:49
Bro Code
Рет қаралды 11 М.
C++ Pass by Value, Reference, Pointer Explained
9:33
Caleb Curry
Рет қаралды 43 М.
Call By Value & Call By Reference in C
8:34
Neso Academy
Рет қаралды 1,3 МЛН
C++ pointers explained easy 👈
5:16
Bro Code
Рет қаралды 34 М.
Pass By Reference | C++ Tutorial
10:21
Portfolio Courses
Рет қаралды 10 М.
C++ structs as arguments explained 🚚
5:29
Bro Code
Рет қаралды 7 М.
why do void* pointers even exist?
8:17
Low Level
Рет қаралды 380 М.