help me fix this code?

solved :)
Last edited on
Since you commented out line 48 (vtime.h) setHours(...) and the other set... functions don't make sense.

addSeconds is simply reduced to:
1
2
3
4
	void addSeconds(int a_seconds)
	{
		m_time += a_seconds;
	}
thank you i really appreciate that. is that the only thing you see wrong?
I think the setHours() etc. functions still make perfect sense. The point of this assignment is to change the data representation while still having the same interface.

You can do setHours() like this:
1
2
3
4
5
setHours(int a_hours) {
    int m = getMinutes();
    int s = getSeconds();
    m_time = a_hours*3600 + m*60 +s;
}

SetMinutes() and setSeconds() will be similar.

addSeconds is easy: just add the number of seconds to m_time;

operator+ can be coded so it works with either data representation:
1
2
3
4
5
6
time time::operator+(int a_seconds)
{
    time tmp(*this);
    tmp.addSeconds(a_seconds);
    return tmp;
}

dhayden: thank you so much for helping me.
Last edited on
Topic archived. No new replies allowed.