//I need help!! Can someone help me!!!
cd.h
#include <iostream>
#include <stdlib.h>
#include <string>
#include <sstream>
using namespace std;
class TimeType {
public:
TimeType();
~TimeType();
TimeType(int & Time1);
TimeType(const TimeType &rhs;);
//void Set( int hours, int minutes,int seconds );
void operator ++();
void operator --();
char Write();
bool Equal( TimeType otherTime ) ;
bool LessThan(TimeType otherTime );
TimeType Difference(TimeType OtherTime);
TimeType operator-(TimeType OtherTime);
int ToSec();
void FromSec(int &Time1;);
private:
int hrs, mins, secs;
};
cd.cpp
#include <iostream>
#include <stdlib.h>
#include "cd.h"
#include <string>
#include <cstring>
#include <sstream>
using namespace std;
TimeType::TimeType()
{
cout << " ** constructor called"<<endl;
return;
}
TimeType::~TimeType()
{
cout << " ** destructor called"<<endl;
return;
}
TimeType::TimeType(const TimeType &rhs;)
{
hrs=rhs.hrs;
mins=rhs.mins;
secs=rhs.secs;
cout << " ** copy constructor called"<<endl;
return;
}
/*
void TimeType::Set( int hours,int minutes, int seconds )
{
hrs = hours;
mins = minutes;
secs = seconds;
string time;
//int time1, time2, time3,time11,time22;
int time1 = atoi(time);
int time2 = atoi(time);
int time3;
char writer[10];
time = time.Write(writer);
}*/
void TimeType::operator ++()
{
secs++;
if (secs > 59)
{
secs = 0;
mins++;
if (mins > 59)
{
mins = 0;
hrs++;
if (hrs > 23)
hrs = 0;
}
}
}
void TimeType::operator--()
{
secs--;
if (secs <0)
{
secs = 59;
mins--;
if (mins > 0)
{
mins = 59;
hrs--;
if (hrs <0)
hrs = 23;
}
}
}
char TimeType::Write(){
char hrs, mins, secs;
hrs = '0';
mins = '0';
secs = '0';
char writer[10];
if (hrs < 10)
hrs = '0';
cout << hrs << ':';
if (mins < 10)
mins = '0';
cout << mins << ':';
if (secs < 10)
secs = '0';
cout << secs;
return writer = (hrs + mins + secs);
}
bool TimeType::operator==( TimeType otherTime ) const
{
return (hrs == otherTime.hrs && mins == otherTime.mins &&
secs == otherTime.secs);
}
bool TimeType::operator<( TimeType otherTime ) const
{
return (hrs < otherTime.hrs ||
hrs == otherTime.hrs && mins < otherTime.mins ||
hrs == otherTime.hrs && mins == otherTime.mins
&& secs < otherTime.secs);
}
TimeType TimeType::Difference(TimeType OtherTime)
{
TimeType LocalTime;
int Time1,Time2;
Time1 = hrs*60*60+mins*60+secs;
Time2 = OtherTime.hrs*60*60+OtherTime.mins*60+OtherTime.secs;
Time1 =abs( Time1- Time2);
LocalTime.secs= Time1`;
LocalTime.mins= (Time1/60)`;
LocalTime.hrs = Time1/60/60;
return LocalTime;
}
TimeType TimeType::operator-(TimeType OtherTime)
{
TimeType LocalTime;
int Time1,Time2;
Time1 = hrs*60*60+mins*60+secs;
Time2 = OtherTime.hrs*60*60+OtherTime.mins*60+OtherTime.secs;
Time1 =abs( Time1- Time2);
LocalTime.secs= Time1`;
LocalTime.mins= (Time1/60)`;
LocalTime.hrs = Time1/60/60;
return LocalTime;
}
int TimeType::ToSec()
{
return hrs*60*60+mins*60+secs;
}
TimeType::TimeType(int & Time1)
{
secs= Time1`;
mins= (Time1/60)`;
hrs = Time1/60/60;
return ;
}
void TimeType::FromSec(int &Time1;)
{
secs= Time1`;
mins= (Time1/60)`;
hrs = Time1/60/60;
return ;
};
int main ()
{
int hrs, mins, secs, hours, minutes, seconds;
TimeType::TimeType();
TimeType();
TimeType(const TimeType &hrs;);
TimeType::Set( int hours,int minutes, int seconds );
operator ++();
operator --();
Write();
Equal( TimeType otherTime ) ;
LessThan(TimeType otherTime );
TimeType Difference(TimeType OtherTime);
TimeType operator-(TimeType OtherTime);
ToSec();
TimeType(int & Time1);
void FromSec(int &Time1;);
return 0;
}Add a code snippet to your website: www.paste.org