I need some help with creating a bool function for my program

So I am kinda stuck and fuzzy on the bools I need a bool function for my program that is called from my getTime function and if the hours, minutes, and second are entered correctly it continues with the program but if it's false it couts invalid time and asks again. Any help would be appreciated thanks guys.

#include "Time.h"
void getTime (Time & time);
void isTimeValid(Time & time);
void addOneSecond(Time & time);
void displayTime(Time & time);
Max_Hours = 23;
Max_Mins = 59;
Max_Secs = 59;

int main()

{ Time t1;
getTime(time);
isTimeValid(time);
addOneSecond(time);
displayTime(time);
return 0;
}
//------------------------------------------------------
void getTime(Time & time)
{
cout << "Enter hour: ";
cin >> time.hours;
cout << " Enter minute: ";
cin >> time.minute;
cout << "Enter seconds: ";
cin >> time.seconds;


}
//------------------------------------------------------
bool isTimeValid(Time & time)
{ if((time.hours >=0) && (time.hours <= Max_Hours))&&



}
First: The prototype void getTime (Time & time); does not match the definition bool isTimeValid(Time & time)

Second: you need to return the bool value. For instance:
1
2
3
4
5
6
bool isTimeValid(Time & time)
{ return ((time.hours >=0) && (time.hours <= Max_Hours))&&...



}


Third you need to do something with the returned value. For instance:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void getTime(Time & time)
{
do
{
cout << "Enter hour: ";
cin >> time.hours;
cout << " Enter minute: ";
cin >> time.minute;
cout << "Enter seconds: ";
cin >> time.seconds;
}
while(!isTimeValid(time));

}
Topic archived. No new replies allowed.