1: //TestStuff31.cpp
  2: //Tuesday, Mar 11, 2014
  3: 
  4: #include <iostream>
  5: #include <string>
  6: #include <iomanip>
  7: #include <cstdlib>
  8: using namespace std;
  9: 
 10: //This myMax.h file must be in your project folder but
 11: //does not have to be added to the project. Note the use
 12: //of double quotes rather than angle brackets. This file
 13: //contains the function "prototype", while the corresponding
 14: //full function definition is in the file myMax.cpp, which
 15: //must be added to the project, is separately compiled, and
 16: //linked with the compiled version of this file to form the
 17: //final exectuable.
 18: 
 19: //This program also requires the following "include file",
 20: //and the corresponding implementation file myMax.cpp.
 21: #include "myMax.h"
 22: 
 23: //This function needs reference parameters because it is
 24: //returning values to the caller.
 25: void GetTwoIntValuesFromUser
 26:         (
 27:         int& first, //out
 28:         int& second //out
 29:         )
 30: {
 31:         cout << "Enter two integer values: ";
 32:         cin >> first >> second;
 33: }
 34: 
 35: //Note the difference here when this function is called,
 36: //and one parameter is called by value, the other by reference.
 37: void DoubleThem
 38:         (
 39:         int first,
 40:         int& second
 41:         )
 42: {
 43:         first = first * 2;
 44:         second = second * 2;
 45:         cout << "The doubled values inside are " << first << " and " << second << "." << endl;
 46: }
 47: 
 48: int main(int argc, char* argv[])
 49: {
 50:         //Rounding a floating point value in C++
 51:         //double x = 3.5163456;
 52:         //double roundedX = (int)((x * 100) + 0.5)/100.0;
 53:         //cout << roundedX << endl;
 54: 
 55:         //string s = "Hello, world!";
 56:         //cout << "w found at index " << s.find('w') << endl;
 57:         //The value returned by find() in the following case is string::npos.
 58:         //cout << "W found at index " << s.find('W') << endl; 
 59: 
 60:         //Note the use of string::npos as the value returned by find()
 61:         //if the character sought is not in fact found.
 62:         //if (s.find('W') != string::npos)
 63:         //        cout << "found" << endl;
 64:         //else
 65:         //        cout << "not found" << endl;
 66: 
 67:         //string request;
 68:         //cout << "Enter your request for action: ";
 69:         //getline(cin, request);
 70:         //const string REQUEST_OPTIONS = "qQcCfF";
 71:         //if (request.length() == 1 && REQUEST_OPTIONS.find(request.at(0)) != string::npos)
 72:         //        cout << "valid" << endl;
 73:         //else
 74:         //        cout << "not valid" << endl;
 75: 
 76:         //cout << myMax(12, 10) << endl;
 77: 
 78:         //int a = -3;
 79:         //int b = -1;
 80:         //cout << myMax(a, b) << endl;
 81: 
 82:         int m = 50;
 83:         int n = 60;
 84:         GetTwoIntValuesFromUser(m, n);
 85:         cout << myMax(m, n) << endl;
 86:         cout << "The values of m and n are now " << m << " and " << n << "." << endl;
 87: 
 88:         DoubleThem(m, n);
 89:         cout << "The doubled values outside are " << m << " and " << n << "." << endl;
 90: }
 91: