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.
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 4. Capitolo 8
Chieda ad AI
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione
Suggested prompts:
Mi faccia domande su questo argomento
Riassuma questo capitolo
Mostri esempi dal mondo reale
Awesome!
Completion rate improved to 2.94
Pass by Reference
Scorri per mostrare il menu
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.
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 4. Capitolo 8