You also might like to see that using classes some times just adds code bloat.
Take a look (no classes) ...
// test_invalid_time_simple.cpp //
#include <iostream>
#include <iomanip> // re. setw, setfill
#include <string>
#include <cctype> // re. toupper
using namespace std;
void print24HourTime(int hr, int min, int sec, const string& );
// used here to take in valid numbers //
int takeInInt( const string& msg, int min, int max,
const string& errmsg = "\nIntegers only please ...\n\n" )
{
int val;
while( true )
{
cout << msg << flush;
if( cin >> val && cin.get() == '\n' )
{
if( val >= min && val <= max ) break;
//else ... if reach here ...
cout << "Valid input range here is: " << min << ".." << max << "\n";
}
else
{
cout << errmsg;
cin.clear(); // clear error flasgs
cin.sync(); // 'flush' cin stream ...
}
}
return val;
}
int takeInChr( const char* msg )
{
cout << msg << flush;
int c = cin.get();
cin.sync(); // 'flush' cin stream
return c;
}
bool more()
{
int c = takeInChr( "More (y/n) ? " );
if( c == 'n' || c == 'N' ) return false;
// else ...
return true;
}
int main ()
{
do
{
string str;
for( ; ; )
{
// do this part firstly ...
// so can see that following hr is AM/PM //
cout << "Enter AM or PM: ";
cin >> str;
cin.sync(); // …