Pass by Reference
By reference:
12345678910void incValue(int &x) { x++; } int main() { int x = 1; incValue(x); cout << x; return 0; }
Here we change x as the function works with the address (reference) of this variable. It can be useful in case you need to change the value of the parameters.
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 4. Kapitel 8
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Awesome!
Completion rate improved to 2.94
Pass by Reference
Svep för att visa menyn
By reference:
12345678910void incValue(int &x) { x++; } int main() { int x = 1; incValue(x); cout << x; return 0; }
Here we change x as the function works with the address (reference) of this variable. It can be useful in case you need to change the value of the parameters.
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 4. Kapitel 8