/* Filename:  params2.cpp

   Author:  Br. David Carlson

   Date:  January 13, 1998

   Revised:  July 20, 2000; November 21, 2001

   This program illustrates various features of parameter passing.

   Tested with:
      Microsoft Visual C++ 6.0
      Microsoft Visual C++ .NET
      g++ under Linux
*/

#include <iostream>
using namespace std;


// Global variable (usually best to avoid):

int b;

// Function prototypes:

int calc(void);

void compute(int & x);


int main(void)
   {
   int ans;

   ans = 1;
   b = 4;
   compute(ans);
   cout << "main -- values of ans, b: " << ans << " " << b << endl;

   return 0;
   }


int calc(void)
   {
   b = 25;
   cout << "calc -- value of b: " << b << endl;
   return b;
   }


void compute(int & x)
   {
   int b;

   b = x + 4;
   cout << "compute -- values of x, b: " << x << " " << b << endl;
   x = calc();
   cout << "compute -- values of x, b: " << x << " " << b << endl;
   }


