WWW W3schools Com CPP CPP - Function - Reference Asp
WWW W3schools Com CPP CPP - Function - Reference Asp
C#
BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY
Pass By Reference
In the examples from the previous page, we used normal variables when we passed
parameters to a function. You can also pass a reference to the function. This can be
useful when you need to change the value of the arguments:
Example
void swapNums(int &x, int &y) {
int z = x;
x = y;
y = z;
}
int main() {
int firstNum = 10;
int secondNum = 20;
// Call the function, which will change the values of firstNum and
secondNum
swapNums(firstNum, secondNum);
Try it Yourself »
❮ Previous Next ❯
COLOR PICKER
SPACES
UPGRADE
NEWSLETTER
GET CERTIFIED
REPORT ERROR
Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
How To Tutorial
SQL Tutorial
Python Tutorial
W3.CSS Tutorial
Bootstrap Tutorial
PHP Tutorial
Java Tutorial
C++ Tutorial
jQuery Tutorial
Top References
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
W3.CSS Reference
Bootstrap Reference
PHP Reference
HTML Colors
Java Reference
Angular Reference
jQuery Reference
Top Examples
HTML Examples
CSS Examples
JavaScript Examples
How To Examples
SQL Examples
Python Examples
W3.CSS Examples
Bootstrap Examples
PHP Examples
Java Examples
XML Examples
jQuery Examples
Get Certified
HTML Certificate
CSS Certificate
JavaScript Certificate
Front End Certificate
SQL Certificate
Python Certificate
PHP Certificate
jQuery Certificate
Java Certificate
C++ Certificate
C# Certificate
XML Certificate
FORUM ABOUT
W3Schools is optimized for learning and training. Examples might be simplified to improve
reading and learning. Tutorials, references, and examples are constantly reviewed to avoid
errors, but we cannot warrant full correctness of all content. While using W3Schools, you
agree to have read and accepted our terms of use, cookie and privacy policy.