Posted by: nepali8 April 12, 2011
C++ Desperately need help!!!
Login in to Rate this Post:     0       ?        
Namaste!!!





 1.        NumDays class

 

Design a class called NumDays. The class’s purpose is to store a value that represents a number of work hours and convert it to a number of days. For example, 8 hours would be converted to 1 day, 12 hours would be converted to 1.5 days, and 18 hours would be converted to 2.25 days. The class will have a constructor that accepts a number of hours, as well as member functions for storing and retrieving the hours and days. The class will also have the following overloaded operators:

 

+ Addition operator. When two NumDays objects are added together, the overloaded + operator will return the sum of the two objects’s hours member.

 

-          Subtraction operator. When one NumDAys object is subtracted from another, the overloaded - operator will return the difference of the two object’s hours member.

 

++ Prefix and postfix increment operators. These operators will increment the number of hours stored in the object. When incremented, the number of days will be automatically recalculated.

 

-- Prefix and postfix decrement operators. Theses operators will decrement the numbers of hours stored in the object. When decremented, the number of days will be automatically recalculated.

 


Last edited: 12-Apr-11 03:56 PM
Read Full Discussion Thread for this article