C++ Programming Tutorial 68 - Swap Function with Pass by Reference

preview_player
Показать описание


~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~

🅑 Bitcoin - 3HnF1SWTzo1dCU7RwFLhgk7SYiVfV37Pbq
🅔 Eth - 0x350139af84b60d075a3a0379716040b63f6D3853
Рекомендации по теме
Комментарии
Автор

The way that I swap ints without using a temp if anyone is interested:
void swap(int &a, int &b){
a = a + b;
b = a - b;
a = a - b;

std::cout << a << ", " << b << "\n";
}

MorbidPasta
Автор

Okay, this one really tied in in better. You almost lost me last video. This was a good enforcer.

guitarhax
Автор

This code is really good Caleb! :D Thanks!

spinity
Автор

THANK GOD bro i was going insane wondering why the numbers weren't swapping, its cause i forgot the &

kabarii
Автор

After watching episode 66-68 I extrapulated that const should be used only when passing arrays to functions. Since all other types are passed by value unless you want the function to have the ability to change the value. Am I understanding this correctly?

kern
Автор

What about swapping back to the original numbers? I want to swap to use for calculation purposes, but then use the original numbers for printing purposes. New to C++. TIA!

DieGedankenSindFrei
Автор

Please tell me how i can do it without any integer on my code. I want to just type two numbers on terminal then i want to got output . For example
Terminal:
10 5
5 10.
. I want to do exactly like that. And i want to left 1 space beatwen integers on terminal also. Beside i want to write just function on my code to implement this output on my terminal.

Yusif
Автор

Hey, did you hear about this IDE that dogs can use to code? ...Sorry, I forgot the punchline. Maybe it was related to a sponsor or something?

PunmasterSTP