0

Function

Why if you put b = 9; F(B); cout < b; in the function Void f(int a) {a = 7;}, then B will be = 9, and not 7

2nd Jan 2025, 9:52 PM
Колоб Масло
Колоб Масло - avatar
2 Réponses
+ 1
Колоб Масло your function parameter is bring passed by value. The parameter, a, gets assigned the value and any change to it remains local to the function. If you want the function to change the variable, b, then use pass by reference, &a. void f(int &a) {...}
3rd Jan 2025, 7:50 AM
Brian
Brian - avatar
0
give us the complete code... I dont understand... https://sololearn.com/compiler-playground/Wek0V1MyIR2r/?ref=app
3rd Jan 2025, 12:01 AM
Ugulberto Sánchez
Ugulberto Sánchez - avatar