// File: DaysElapsedInYear.cpp // Days Elapsed application; uses polymorphism to access date info // Prepared by Dr. Spiegel #include #include #include "Year.h" #include "LeapYear.h" using namespace std; /*! * Get date off command line * Print days elapsed in year to that date via polymorphic call to function * */ int main(int argc,char **argv) {if (argc==1) { cerr << "Form: days \n"; exit(-1); } int month=atoi(argv[1]), day=atoi(argv[2]), year=atoi(argv[3]); Year *theDate; // Initialize theDate to refer to the correct object type // Can use LeapYear to access static method if (Year::isLeapYear(year)) theDate=new LeapYear(month,day,year); else theDate=new Year(month,day,year); cout << "Days Elapsed: " << theDate->daysElapsed() << endl; }