figure_me_out.cpp

Figure_me_out.cpp - changed in the function#include<iostream> using namespace std void figure_me_out(int& x int y int& z int main int a

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//1. The variables being treated as a reference in this example are x and z. //2. A function that returns a value can have a call-by-reference paramter. //3. A function can have both call-by-value and call-by-reference parameters //figure_me_out is setting x and z to 1 and 3 respectively and outputting those values along with b as 2. However, x and z are call-by-reference parameters and so the main now has the values set as 1 and 3, as well as in the function; the y parameter is only
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: changed in the function. #include <iostream> using namespace std; void figure_me_out(int& x, int y, int& z); int main() { int a, b, c; a = 10; b = 20; c = 30; figure_me_out(a, b, c); cout << a << " " << b << " " << c; return 0; } void figure_me_out(int& x, int y, int& z) { cout << x << " " << y << " " << z << endl; x = 1; y = 2; z = 3; cout << x << " " << y << " " << z << endl; }...
View Full Document

This note was uploaded on 04/17/2008 for the course EECS 168 taught by Professor Miller during the Spring '08 term at Kansas.

Ask a homework question - tutors are online