#include #include using namespace std; // 3 function prototypes for overloaded functions that // appear below main void myNames(string a, string b, string c); void myNames(string n); int myNames(string n, string two); int SumUp(int z, int q) // pass by value { // just like Las Vegas, what's happens in the function // stays in the funtion int sum; sum = z+q; // prints out every time you run the function // cout << "From SumUp: " << sum << endl; return sum; } void DoubleByReference(int &d, int &e) // pass by reference { // Not Las Vegas, or not good friends // They tell main() what happened d = d*2; e = e*2; // these values change the variables that are being // referenced. They change for good. We now changed // their values in main() } void doubleNum(int &Var) { // pass by reference Var = Var * 2; // will also change value in main() } void myArrayFunction(string myNames[]) { myNames[0] = "Larry"; myNames[1] = "Currley"; myNames[2] = "Moe"; cout << myNames[0] << endl; cout << myNames[0][1] << endl; } int main() { int a=1, b=2; int i = 12; SumUp(a, b); // we are passing variable values SumUp(23,50); // we are passing actual values cout << "From main: " << SumUp(a, b) << endl; cout << "i = " << i << endl; // value of i cout << "Address of i " << &i << endl; // address of i // the address of i is called a "reference" cout << "Address of a " << &a << endl; string name = "Barbara"; char charName[] = {'B', 'a', 'r', 'b', 'a', 'r', 'a'}; cout << "charName= " << charName << endl; cout << "name= " << name << endl; cout << name[0] << endl; cout << charName[0] << endl; string MoreNames[10]; // array of 10 strings MoreNames[0] = "Larry"; MoreNames[1] = "Currly"; MoreNames[2] = "Moe"; cout << "Like a 2-dimension: " << MoreNames[1][2] << endl; // 3 rows and 6 columns // L a r r y _ (row 1) // C u r r l y (row 2) // M o e _ _ _ (row 3) char myDoubleArray[3][6]; // 3 rows and 6 columns myDoubleArray[0][0] = 'L'; myDoubleArray[1][0] = 'C'; myDoubleArray[2][0] = 'M'; myDoubleArray[0][1] = 'a'; myDoubleArray[1][1] = 'u'; myDoubleArray[2][1] = 'o'; int myDoubleIntArray[5][5]; cout << endl << endl << endl; int l=0, y=0; // populate the array with all 1's // The loop was correct, it was printing it out that wasn't working // during the class. for (l=0; l<5; l++) { for (y=0; y<5; y++) { myDoubleIntArray[l][y] = 1; } } string antherlistofname[5]; myArrayFunction(antherlistofname); cout << "After the function call, #2 is " << antherlistofname[1] << endl; i = 2; doubleNum(i); cout << "After doubleNum: " << i << endl; doubleNum(i); cout << "After doubleNum again...: " << i << endl; return 0; } // the fuction myNames is overloaded three times! void myNames(string a, string b, string c) { } void myNames(string n) { } int myNames(string n, string two) { return 0; }