Pass by Value
Veeg om het menu te tonen
When we pass function arguments, there are two ways to do this:
- By value: the function's variable copies the parameter's value without changing the argument.
- By reference: the function's variable copies the reference of the parameter by changing the argument.
By value:
12345678910void incValue(int x) { x++; } int main() { int x = 1; incValue(x); cout << x; return 0; }
As you can see by the output, x didn't change since we changed the copy of x in the function incValue().
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 4. Hoofdstuk 7
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Sectie 4. Hoofdstuk 7