【正文】
r name void displayMessage()。 // instructor name for this GradeBook}。 pass a course name and instructor name GradeBook gradeBook( CS101 Introduction to C++ Programming, Professor Smith )。 // assume that the balance begins at 0 // if initialBalance is greater than 0, set this value as the // balance of the Account。 // prompt cin withdrawalAmount。 void setPartDescription( string )。 // store partNumber setPartDescription( description )。 } // end if} // end function setPricePerItem// get price per itemint Invoice::getPricePerItem(){ return pricePerItem。 // display the modified invoice data members and calculate new amount cout Part number: () endl。s first name string lastName。 // set monthlySalary to } // end function setMonthlySalary// return monthly salaryint Employee::getMonthlySalary(){ return monthlySalary。 // display each Employee39。 // return year void displayDate()。} // end function setDay// return dayint Date::getDay(){ return day。 // output the Date as 5/6/1981 // modify the Date ( 13 )。 // end class Complex endif類成員函數(shù):include iostream using std::cout。 // output object a cout + 。 return 0。 // end class Rationalendif類成員函數(shù):include iostream using std::cout。 ()。 else if ( numerator == 0 ) // validates numerator cout 0。 using std::endl。 // prints rational object c cout 。 ()。 // prints rational object x cout = 。 // 0 23 (24hour clock format) int minute。amp。 ) setw( 2 ) getMinute() : setw( 2 ) getSecond() ( hour 12 ? AM : PM )。 // set month, day, year void setMonth( int )。 // invokes function setMonth setDay( dy )。 } // end function getMonthint Date::getYear() { return year。amp。 // set month void setDay( int )。 return 0。 year % 100 != 0 ) ) return true。 m = 1 ? m : 1。 // days in month }。 // invokes function tick } // end for return 0。039。 // set private field second} // end function setTime// set hour valuevoid Time::setHour( int h ){ hour = ( h = 0 amp。 // return second void tick()。 ()。 // prints rational object c cout x 。 // prints rational object x cout = 。 denominator % loop == 0 ) gcd = loop。 ()。s ){ Rational t。 // print rational as double formatprivate: int numerator。 // output object b cout = 。} // end function setComplexNumber測試函數(shù):include iostream using std::cout。 // print plex number format void setComplexNumber( double, double )。 cout Day: () endl。 if ( month 1 ) month = 1。 // return month void setDay( int )。s monthly salary multiplied by 12 int monthlySalary2 = ()。 // no validation needed} // end function setLastName// return last namestring Employee::getLastName(){ return lastName。 // return last name void setMonthlySalary( int )。 ( Saw )。} // end function getQuantity// set price per item。 // end class Invoice類成員函數(shù):include iostreamusing std::cout。 // indicate successful termination} // end main類定義:include string // program uses C++ standard string classusing std::string。 // create Account object // display initial balance of each object cout account1 balance: $ () endl。 // data member that stores the balance}。s name cout This course is presented by: getInstructorName() endl。 // function to set instructor name string getInstructorName()。 // end class GradeBook類成員函數(shù):include iostreamusing std::cout。 // display initial value of instructorName of GradeBook object cout gradeBook instructor name is: () \n\n。 otherwise, balance remains 0 if ( initialBalance 0 ) balance = initialBalance。 // obtain user input cout \nattempting to subtract withdrawalAmount from account1 balance\n\n。 // part description string getPartDescription()。 // store partDescription setQuantity( count )。} // end function getPricePerItem// calulates invoice amount by multiplying quantity x price per itemint Invoice::getInvoiceAmount(){ return getQuantity() * getPricePerItem()。 cout Part description: () endl。 // Employee39。} // end function getMonthlySalary測試函數(shù):include iostreamusing std::cout。s yearly salary again cout \nEmployees39。 // displays date in mm/dd/yyyy formatprivate: int month。} // end function getDay// set yearvoid Date::setYear( int y ){ year = y。 // invalid month ( 1 )。 include Complex::Complex( double real, double imaginary ){ setComplexNumber( real, imaginary )。 ()。} // end main類定義:ifndef RATIONAL_Hdefine RATIONAL_Hclass Rational {public: Rational( int = 0, int = 1 )。 include // include definition of class RationalRational::Rational( int n, int d ){ numerator = n。 // store the fraction in reduced form return t。 else cout numerator 39。 include // include definition of class Rationalint main(){ Rational c( 2, 6 ), d( 7, 8 ), x。 ()。 // prints rational object x cout 39。 ()。 // 0 59 int second。 m 60 ) ? m : 0。} // end function printStandard測試函數(shù):include iostream using std::cout。 // set month void setDay( int )。 // invokes function setDay setYear( yr )。 } // end function getYearvoid Date::print(){ cout month 39。 leapYear() ? 29 : days[ month 1 ]。 // set day void setYear( int )。 // invokes function next day } // end for cout endl。amp。amp。 // leap year int monthDays()。 ()。 // increment hour by 1 } // end if } // end function tick// print Time in universaltime format (HH:MM:SS)void Time::printUniversal(){ cout setfill( 39。 // set private field minute setSecond( s )。 // return minute int ge