I am trying to increment the days to change over to the next day and year. Here is my code so far, but I keep getting one error.
here is the error code I get.Code:#include <iostream> using std::cout; using std::endl; // class Date definition class Date { public: Date( int = 1, int = 1, int = 1990 ); // default constructor void print(); private: int month; int day; int year; }; // end class Date // Date constructor with range checking Date::Date( int m, int d, int y ) { void incrementDay( Date &, const int ); // prototype int main() {// Date t; // create Date object // set time using individual set functions t.setMonth( 17 ); // set month to valid value t.setDay( 34 ); // set day to valid value t.setYear( 25 ); // set year to valid value // use get functions to obtain month, day and year cout << "Result of setting all valid values:\n" << " Month: " << t.getMonth() << " Day: " << t.getDay() << " Year: " << t.getYear(); // set date using individual set functions t.setMonth( 234 ); // invalid month set to 0 t.setDay( 43 ); // set day to valid value t.setYear( 6373 ); // invalid year set to 0 // display month, day and year after setting // invalid day and year values cout << "\n\nResult of attempting to set invalid Date:\n" << " month:\n Month: " << t.getMonth() << " Day: " << t.getDay() << " Year: " << t.getYear() << "\n\n"; t.setDate( 11, 30,2000 ); // set time incrementDay( t, 3 ); // increment t's day by 3 return 0; } } // end constructor Date // print Date in the format mm-dd-yyyy void Date::print() { cout << month << '-' << day << '-' << year; } // end function print int main() { Date date1( 7, 4, 2002 ); Date date2; // date2 defaults to 1/1/1990 cout << "date1 = "; date1.print(); cout << "\ndate2 = "; date2.print(); date2 = date1; // default memberwise assignment cout << "\n\nAfter default memberwise assignment, date2 = "; date2.print(); cout << endl; return 0; }
C:\Documents and Settings\Local Settings\Temp\Fig06_24.cpp(30) : error C2601: 'main' : local function definitions are illegal
Error executing cl.exe.
A friend of mine also recommended putting another member function? in that runs the test.