WAP to create class Date having three private data members (day, month, year). Class should have (i) appropriate constructors (ii) member functions to calculate days since a given date, int days(Date d) (iii) display date (iv) Boolean method isEarlier(Date d) to find whether d is after or before calling date object. Note – Do not take care of leap year matter, let Feb be 28 days always.
WAP which uses the Date class to represent date of birth objects. Given two dates of birth write code to find the age difference between them. Note – treat current date also as an object
Doubt: I have a doubt in question. What exactly should the functionint days(Date d) do? Should it calculate no of days from starting of year till Date d or should it calculate difference in number of days between 2 dates?
What exactly should the function int days(Date d) do? Should it calculate no of days from starting of year till Date d or should it calculate difference in number of days between 2 dates?
Since it is a member function with a date parameter, then there are two dates involved, the current object, and the one which is passed when calling the function. It seems to mean that it is the interval in days between those two dates which should be calculated.