// 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; // Forgive me for violating ordering convention // Parameter MUST be a reference void printResult(Year &theDate) { cout << theDate.daysElapsed() << endl; } // Will be called when Return is pressed in the TextField 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; cout << "Days Elapsed as of " << month << "/" << day << " is "; // Initialize theDate to refer to the correct object type // Can use LeapYear to access static method if (Year::isLeapYear(year)) { LeapYear LY(month,day,year); printResult(LY); } else { Year Y(month,day,year); printResult(Y); } }