Hi kbc08,
This first point is a technical style one:
This brings in all kinds of things into your program that aren't neccessary. If you are only using cout and cin, then you do this instead:
1 2
|
using std::cout;
using std::cin;
|
This won't make any difference to the running of your program, but makes it easier on the compiler / optimiser.
Now for the array of month names:
1 2 3
|
const string MONTHS[13] = {" ", "Januray", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"};
|
The best thing to do, is declare them as an
enum with january = 1
If you did want to keep them as an array and you declare and initialise on the same line, you can leave the index size in the [] blank, as the compiler will count them for you.
I am guessing you had the size as 13 to get over the problem of the array starting at zero. Using the enum will get over this problem, although it's not that hard to code with arrays that start at 0.
With the isleapyear function, it is more complicated than every 4 years. A clue is that the rules are different every 100 & 400 years. Look on Wiki.
With the dayofweek function there is a problem with integer division.
What does this do?
1 2
|
for startday>>num.days
|
In function printyear, look at where the variable i is set, then look at the other places it is used. Where is the value of i changed? Is that what you want? Look at the index expressions of the for loops, and decide if they are being used properly inside the for loops.
One problem is the names you have for variables. I never use i (or any single letter)for a loop counter, it is too easily confused with one or j. It is much better to use a word (like you have with index etc) but that it is even better to qualify it further by saying what sort of counter or index that it is. E.g. use DayCounter, MonthCounter etc. Google C++ coding standard (not the C++ ANSI standard) to see how professional programmers do it. There is one at LinuxQuestions.org
Let us know how you go.
TheIdeasMan