
Patrick B. answered 08/08/21
Math and computer tutor/teacher
typedef
class TimeStamp
{
protected:
int sec;
int min;
int hour;
public:
TimeStamp() { sec=min=hour=0; }
TimeStamp(int s, int m, int hr) { sec=s; min=m; hour=hr; }
friend ostream& operator<<(ostream& os, const TimeStamp& t)
{
os << t.sec<< ':' << t.min << ':' << t.hour <<endl <<flush;
return os;
}
bool operator<(TimeStamp t)
{
bool boolReturn;
if (this->hour != t.hour)
{
boolReturn =this->hour<t.hour;
}
else
{
if (this->min!=t.min)
{
boolReturn=this->min <t.min;
}
else
{
boolReturn =this->sec<t.sec;
}
}
}
bool operator==(TimeStamp t)
{
return(
(this->hour==t.hour)&& (this->min==t.min) && (this->sec==t.sec)
);
}
} * TTimeStamp;
#define TIME_STAMP_SIZE (sizeof(TimeStamp))
int main()
{
int times[][3] = { {15,34,23},
{13,13,2},
{43,45,12},
{25,36,17},
{52,02,20}
};
TTimeStamp timeStamps = new TimeStamp[5];
SortedType<TimeStamp> sortedTimeList;
for (int iLoop=0; iLoop<5; iLoop++)
{
timeStamps[iLoop]=TimeStamp(times[iLoop][0],times[iLoop][1],times[iLoop][2]);
sortedTimeList.InsertItem(timeStamps[iLoop]);
}
TimeStamp targetTimeStamp(25,36,17);
sortedTimeList.DeleteItem(targetTimeStamp);
int N=sortedTimeList.LengthIs();
sortedTimeList.ResetList();
for (int iLoop=0; iLoop<N; iLoop++)
{
TimeStamp curTimeStamp;
sortedTimeList.GetNextItem(curTimeStamp);
cout <<curTimeStamp;
}
}