please help me

Rewrite the header and body of SetHour, SetMinute, and SetSecond functions in the Time class to enable invoking these functions sequentially in the same statement (cascaded function calls). For Example, suppose T1 is an object of Time class, so you can call SetHour, SetMinute, and SetSecond functions as follows:

T1. SetHour (14). SetMinute (15). SetSecond(45);
class Time

{

public:

Time(int hour, int minute, int second)

{

SetHour(hour);

SetMinute(minute);

SetSecond(second);

}



int GetHour() { return hr; }

int GetMinute() { return min; }

int GetSecond() { return sec; }

void SetHour(int h)

{

this->hr= (0 <= h && h < 24) ? h : 0;

}

void SetMinute(int m)

{

this->min = (0 <= m && m < 60) ? m : 0;

}

void SetSecond(int s)

{

this->sec = (0 <= s && s < 60) ? s : 0;

}

private:

int hr; // Hour

int min; // Minute

int sec; // Second

};

please help me faster
Your set functions need to return a reference to the Time object they are working on.

http://www.cplusplus.com/forum/general/143639/
Last edited on
Please use code tags so that the code is readable!
Topic archived. No new replies allowed.