ganesh_IT 0 Light Poster

Hi guys, i try to write a containment program with Date and Time classes, i have problem in operator loading in Date_Time.

class Date{
	short d, m ,y;
public:
	Date();
	Date(short date, short month, short year);
	~Date();
	short Day() const;
	short Month() const;
	short Year() const;
	
};
Date operator+(Date d, shortn)
{
       return add_day(d, n);
}
Date add_day(Date d, short n) 
{
	int max, temp, month = d.Month(), year = d.Year(), day = d.Day();
	temp = d.Day() + n ;
	
	max = maxdays(month, year);
	while (temp > max )
	{
		max = maxdays(month, year);
		month += 1;
		temp = temp - (max );
		day = 0;
		if(month > 12)
		{
			year += month / 12;
			month = 1;
		}
		max = maxdays(month, year);
	}
	day = temp ;
	return Date(day, month, year);
}
class Time{
	short hr, min, sec;
	bool am_pm;
public:
	Time();
	Time(short hour, short minutes, short seconds, bool meri);
	~Time();
	short Hour() const;
	short Minutes() const;
	short Seconds() const;
	bool Meridian() const;
};
Time operator+(Time t, short n)
{
        return add_minutes(t, n); //add minutes and as constructor as like date
}
Containment class 
class Time{
	short hr, min, sec;
	bool am_pm;
public:
	Time();
	Time(short hour, short minutes, short seconds, bool meri);
	~Time();
	short Hour() const;
	short Minutes() const;
	short Seconds() const;
	bool Meridian() const;
};

class Date_Time{
	Date d;
	Time t;
public:
	Date_Time();
	Date_Time(short date, short month, short year, short hour, short minutes, short seconds, bool meri);
	Date_Time(Date dd, Time tt);
	~Date_Time();
	short Day() const;
	short Month() const;
	short Year() const;
	short Hour() const;
	short Minutes() const;
	short Seconds() const;
	bool Meridian() const;
	Date DObj() const;
	Time TObj() const;
	
};
 //i need to overloadd +opertor for both time and date using Date_Time type, i dont know how to do it...

Date_Time opertor+(Date_Time dt, int n)
{
}

thanks....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.