// Lab11-3-Debugging.cpp // demonstrates passing structure as argument #include using namespace std; //*************************************************************************** struct Distance { // English distance int nFeet; float fInches; }; //*************************************************************************** void DisplayEnglishDistance(Distance dToDisplay); // Function declaration void EditEnglishDistance(Distance dToEdit); // Function declaration //*************************************************************************** //int main() //*************************************************************************** int main() { Distance dLength1, dLength2; // Declare and define two Distance objects // Get length dLength1 from user cout << "Enter Feet: "; cin >> dLength1.nFeet; cout << "Enter Inches: "; cin >> dLength1.fInches; // Get length dLength2 from user cout << "\nEnter Feet: "; cin >> dLength2.nFeet; cout << "Enter Inches: "; cin >> dLength2.fInches; cout << "\ndLength1 = "; DisplayEnglishDistance(dLength1); // Display contents of first length cout << "\ndLength2 = "; DisplayEnglishDistance(dLength2); // Display contents of second length EditEnglishDistance(dLength2); // Send second length object to editing cout << "\ndLength2 = "; DisplayEnglishDistance(dLength2);// Display length 2 return 0; } //*************************************************************************** // DisplayEnglishDistance(Distance dToDisplay) // display structure of type Distance in nFeet and fInches //*************************************************************************** void DisplayEnglishDistance(Distance dToDisplay) // Definition of function { cout << dToDisplay.nFeet << "\'-" << dToDisplay.fInches << "\"\n"; } //*************************************************************************** // void EditEnglishDistance(Distance dToEdit) //*************************************************************************** void EditEnglishDistance(Distance dToEdit) // Definition of function { cout << "\nEditing existing object. dToEdit = "; DisplayEnglishDistance(dToEdit); cout << "Enter Feet: "; cin >> dToEdit.nFeet; cout << "Enter Inches: "; cin >> dToEdit.fInches; cout << "\nAfter input, dToEdit = "; DisplayEnglishDistance(dToEdit); }