please help me

Sep 2, 2020 at 6:17am
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
Sep 2, 2020 at 8:15am
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 Sep 2, 2020 at 8:16am
Sep 2, 2020 at 9:59am
Please use code tags so that the code is readable!
Topic archived. No new replies allowed.