// ***************************************************************** // Author: Zhixiang Chen // Class: CSCI/CMPE 1170, 2009 // Lab Optional 2: Function overloading and static local variables // Date: January 17, 2009 // Comment: The code here is meant to be revised. // //----------------------------------------------------------------- // // This lab exercise is to show how to give multiple definitions to // to a function and how to use different definitions. We also try // to experiment static local variables // // Compile and run your program. When everything is fine, // print your .cpp and .h files and turn them to me or the TA. // ***************************************************************** #include < iostream > #include #include < string > #include < cstring > #include < cmath> #include #include //include header file #include "lab_optional_2_head.h" using namespace std; int main( ) { /*************************************************************** Part A. Practice function overloading I have defined three copies of the function swapAndLarger but need to complete the fourth copy to deal with C++ strings ***************************************************************/ //variable declaration int number1, number2, intLarger; //vars to store two int values char ch1, ch2, charLarger; //vars to store to char values string word1, word2, wordLarger; //vars for two C++ strings char str1[50], str2[50], strLarger[50]; //vars for two arrays of 50 chars //get info from the user cout<<"Enter two integers => "; cin>>number1>>number2; //get two integers cout<<"Enter two characters => "; cin>>ch1>>ch2; //get two characters cout<<"Enter two words => "; cin>>word1>>word2; //get two C++ strings cout<<"Enter two words again => "; cin>>str1>>str2; //get two C strings //call swapAndLarger() to deal with integers intLarger = swapAndLarger(number1, number2); //the type of paramters determines which definition is used cout<<"The larger of " <