Contenido del Curso
C++ Intermediate | Mobile-Friendly
C++ Intermediate | Mobile-Friendly
Pass by Reference
By reference:
void 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.
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 4. Capítulo 8