// Mr. Minich
// Computer Science Using C++
// September 9, 2000
// Ch. 9 Demo Program #4
// Purpose - to illustrate examples of passing by reference, by value,
// & by address.
#include <iostream.h>
#include "M:\C++ Programming\AP classes\apstring.h"
// Since I've decided to place the function definitions
// above the main function which calls the functions, function
// prototypes are not required. (This is bad style, but possible.)
void passByVal(int a)
{
a = 100;
}
void passByRef(int &frankGoody2Shoes)
// Notice that the use of the ampersand (&) causes the
// parameter to be passed by reference.
{
frankGoody2Shoes = 100;
}
void passByAddress(char pseudonym[])
{
pseudonym[0] = ' ';
}
int main()
{
int pope = 5;
int billyTheKid = 3;
apstring address = "scot";
passByVal(pope);
passByRef(billyTheKid);
passByAddress(address);
cout << "This variable was passed by value: " << pope << endl;
cout << "This variable was passed by reference: " << billyTheKid << endl;
cout << "This string was passed by address: " << address << endl;
return 0;
}// end of main