Hi there, I'm trying to do a program that allows user to enter a number between 1-365 and convert that to month and day (for example, 32 -> Feb. 1st). I tried compiling the program but I got "expected primary expression before '.' token" in int main(). I can't seem to figure out what I did wrong. If any of you can just point me in the right direction, that'll be awesome. Thank you so much!
thanks!!Code://This program is for chapter 14 - review question 2 - Day of the year #include <iostream> #include <string> using namespace std; class DayOfYear { private: static const int daysAtEnd[]; static const int monthNames[]; public: void DayOfYear::print() { int month = 0; int day; while (daysAtEnd[month] < day) month = (month+1)%12; if (month == 0) cout << "January" << day; else { cout << DayOfYear::monthNames[month]<< " " <<day - DayOfYear::monthNames[month-1]; } } void DayOfYear::setNumber(int n) { int number; if (n >= 0 && n <= 365) number=n; else { cout << n << "is not a valid" << "value for the month.\n"; exit (EXIT_FAILURE); } } }; int daysAtEnd[12] = {31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}; char monthNames[] = "January, February, March, April, May, June, July, August, September, October, November, December"; int main() { DayOfYear.print(); <--- expected primary expression before "." token system("PAUSE"); return 0; }



LinkBack URL
About LinkBacks




