+ 1

PassByValue

How do you do the pass by value question?

28th Jan 2019, 10:28 PM
Anthony Gonzales
Anthony Gonzales - avatar
3 Respostas
+ 3
Pass by value: void value(int a) { a += 5; // only changes a inside the function } By Reference: void reference(int& a) { a += 5; // changes the passed variable } int x = 10; value(x); // x is still 10 reference(x); // x is now 15
29th Jan 2019, 4:13 AM
Zeke Williams
Zeke Williams - avatar
+ 3
How should anyone know what you're even talking about?
28th Jan 2019, 10:42 PM
HonFu
HonFu - avatar
+ 1
normally 'pass'; if(x==2) pass; and finished... Is that what you want to say?
28th Jan 2019, 10:44 PM
Ümit YAVUZ
Ümit YAVUZ - avatar