【正文】
// end function getQuantity// set price per item。using std::endl。 ( Saw )。 cout Invoice amount: $ () endl。 // return last name void setMonthlySalary( int )。s salary per month}。 // no validation needed} // end function setLastName// return last namestring Employee::getLastName(){ return lastName。 Employee employee2( Mark, Stein, 4000 )。s monthly salary multiplied by 12 int monthlySalary2 = ()。s monthly salary multiplied by 12 monthlySalary1 = ()。 // return month void setDay( int )。 // the year of the date}。 if ( month 1 ) month = 1。/39。 cout Day: () endl。 ()。 // print plex number format void setComplexNumber( double, double )。} // end function addComplex Complex::subtract( const Complex amp。} // end function setComplexNumber測(cè)試函數(shù):include iostream using std::cout。 // invoke add function and assign to object c ()。 // output object b cout = 。 // function addition Rational subtraction( const Rational amp。 // print rational as double formatprivate: int numerator。 // store the fraction in reduced form} // end Rational constructorRational Rational::addition( const Rational amp。s ){ Rational t。 // creates Rational object = * numerator。 ()。} // end function printRationalvoid Rational::printRationalAsDouble() { cout static_cast double ( numerator ) / denominator。 denominator % loop == 0 ) gcd = loop。 ()。 // prints rational object x cout = 。 ()。 // prints rational object c cout x 。 // prints rational object x cout = 。 ()。} // end main類定義:ifndef TIME_Hdefine TIME_Hclass Time {public:public: Time( int = 0, int = 0, int = 0 )。 // return second void tick()。include iomanipusing std::setfill。 // set private field second} // end function setTime// set hour valuevoid Time::setHour( int h ){ hour = ( h = 0 amp。 s 60 ) ? s : 0。039。int main(){ Time t。 // invokes function tick } // end for return 0。 // get month int getDay()。 // days in month }。 leapYear() ) day = ( d = 29 amp。 m = 1 ? m : 1。39。 year % 100 != 0 ) ) return true。 include // include definitions of class Dateint main(){ const int MAXDAYS = 16。 return 0。 // set hour, minute, second void setHour( int )。 // set month void setDay( int )。 loop = MAXDAYS。amp。 // increments day by 1 if ( day == 1 ) { setMonth( month + 1 )。 } // end function getMonthint Date::getYear() { return year。amp。 // invokes function setMonth setDay( dy )。 // 112 int day。 // set month, day, year void setMonth( int )。 ticks MAX_TICKS。 ) setw( 2 ) getMinute() : setw( 2 ) getSecond() ( hour 12 ? AM : PM )。} // end function getSecond// increment one secondvoid Time::tick(){ setSecond( getSecond() + 1 )。amp。 // validate and set time } // end Time constructor // set new Time value using universal time。 // 0 23 (24hour clock format) int minute。 // set minute (after validation) void setSecond( int )。 // prints rational object x cout = 。 // prints rational object c cout / 。 ()。 // prints rational object x cout = 。 // prints rational object c cout 。 ()。 using std::endl。 // greatest mon divisor for ( int loop = 2。 else if ( numerator == 0 ) // validates numerator cout 0。} // end function multiplicationRational Rational::division( const Rational amp。 ()。 = * denominator。 // end class Rationalendif類成員函數(shù):include iostream using std::cout。 // function multi. Rational division( const Rational amp。 return 0。 // reset realPart and ( 11, 5 )。 // output object a cout + 。 realPart , imaginaryPart 39。 // end class Complex endif類成員函數(shù):include iostream using std::cout。 )。 // output the Date as 5/6/1981 // modify the Date ( 13 )。 } // end function displayDate測(cè)試函數(shù):include iostreamusing std::cout。} // end function setDay// return dayint Date::getDay(){ return day。// assume values provided are correct (really should validate)Date::Date( int m, int d, int y ){ setMonth( m )。 // return year void displayDate()。 return 0。 // display each Employee39。 // retrieve and display employee139。 // set monthlySalary to } // end function setMonthlySalary// return monthly salaryint Employee::getMonthlySalary(){ return monthlySalary。 // store last name setMonthlySalary( salary )。s first name string lastName。 // constructor sets data members void setFirstName( string )。 // display the modified invoice data members and calculate new amount cout Part number: () endl。 cout Quantity: () endl。 } // end if} // end function setPricePerItem// get price per itemint Invoice::getPricePerItem(){ return pricePerItem。 if not positive, set to 0void Invoice::setQuantity( int count ){ if ( count 0 ) // if quantity is positive quantity = count。 // store partNumber setPartDescription( description )。 // the number of the part being sold string partDescription。 void setPartDescription( string )。 ( withdrawalAmount )。 // prompt cin withdrawalAmount。using std::cin。 // assume that the balance begins at 0 // if initialBalance is greater than 0, set this value as the // balance of the Account。 // constructor initializes balance void credit( int )。 pass a course name and instructor name GradeBook gradeBook( CS101 Introduction to C++ Programming, Professor Smith )。 // store the instructor name} // end function setInstructorName// function to retrieve the instructor namestring GradeBook::getInstructorName(){ return instructorName。 // in