What is the incorrect action and why does it occur?
Specification: When the object is created, the program below should set the time to HR:MIN:SEC. The ++ operator should increment the minute value. When the fifty-ninth minute is incremented, the HR is incremented and the MIN is reset to 0. Note: Only the class functions are presented here.
```
class Time
{
private:
int hr, min, sec;
public:
Time(int h, int m, int s) { hr = h; min = m; sec = m; }
void operator ++ ();
};
void Time::operator ++ ()
{
min++;
if(min == 59)
{
hr++;
min = 0;
}
}
```
This program contains an inaccurate assignment in the constructor function. The minute value is being assigned to the second variable.
The ++ function contains a logic error. When the time contains the 58th minute, the minute will be incremented and the check in the if statement will then increment the hour and set the minute back to zero. This is incorrect. The check statement should be:
if(min == 60)
You might also like to view...
A PivotChart has a category axis and a ________ axis
A) column B) row C) filter D) value
Web applications, hosted on a Web server, access data stored in a database client available on the World Wide Web.
Answer the following statement true (T) or false (F)