Re: class date problem.....

Please use the code tags.

Quote:

*Originally posted by Forever82 *

**1) how can i validate the months , days and year together with the subclass earlier, if the year same...nothing provided.,. no result.pls show example...**

2)i really have no idea on counting the next christmas day by providing a specified date on my christmas subclass.pls show me some examples..

3)how to count the different between the two dates....by using the below class... any clues...will be appreciate

1) I'm not sure what you're trying to ask. It seems like you've got the idea of validating the month and date data already.

2) Be more specific. Do you want to know the date of the next Christmas? Or how many days until the next one?

3) I'll be general with my answer. To find the difference between two dates, I know of two methods. Compute the number of days from an "absolute zero" of both dates, and subtract. Compute just the amount between the two dates. I prefer the first because in most cases, the numbers won't over run an int. And it's just so much simpler to code. To compute the difference by finding the gaps, you take a sum of a bunch of "pieces". For example, find the number of days until the end of date1's month (assuming date2 is in a different month), then find the number of days until the end of date1's year (assuming date 2 is in a different year), find the number of days in the years between date1 and 2 (if any), find the number of days up to the start of date2's month, add the the date of the month of date2.

There may be other ways, but I've never had any real problems with the first method so I never looked into it much. I also find using the first method a much easier way to take into account the weird rules about leap years.

~SK

reply to unsolved problem

1) what i am trying to say is, with my function earlier..... yes.... i can differentiate the two dates before and after...but just by putting the comparison depending on the variable of year<Eyear... like this i can't check if the date is in same year and it can't verify the month and day....i have try by putting

if(year>=year && month<Emonth && day<Eday)

cout<<"before";

else

cout<<"after";

but cannot work.....

2)what should i declare inside the Christmas function to count a e.g date1 is 12 26 1970 (count howmany days until the next christmas )

3)is it a must that i use overloaded operators to count in class by inheritance..??? By using my method....can i still count the different and add ...... if can......pls show me how......