PDA

View Full Version : C++ Question



Damnatory
10-18-2003, 07:17 PM
This is probably a stupid question, but the only error I am getting keeps the program from compiling stating that: " To few parameters in call to DayCount( int, int )

Heres the code, and I'll bold the call..


#include <iomanip.h>
#include <iostream.h>
#include <conio.h>
#include "calender.h"

int main( )
{
&nbsp; int m;
&nbsp; int y;
&nbsp; int xLeapyear;
int days;
&nbsp; char *monthName[12] = {
"January","February","March","April","May","June","July","August",
"September","October","November","December" };

&nbsp; cout << "Enter the Month in question by its value (Ex. 1-12): " << endl;
&nbsp; cin >> m;

&nbsp; if ( m <= 0 || m >= 13 ) {
cout << "Error, month value invalid." << endl;
getch();
return 1;
&nbsp; }//endif

cout << "Please enter the year in question (Ex. 2000(xxxx))" << endl;
cin >> y;

if ( y < 1582 ) {
&nbsp; cout << "Years before 1582 were all Leap Years, try again." << endl;
&nbsp; getch();
&nbsp; return 1;
}//endif

if ( m > 0 && m < 13 ) {
&nbsp; days = DayCount( m );
&nbsp; xLeapyear = LeapYear(y);
&nbsp; if ( m == 2 && xLeapyear == 1 ) {
days = 29;
&nbsp; }else{
if ( m == 2 ) {
&nbsp; days == 28;
}//endif
&nbsp; }//endif

cout << "There are " << days << " days in " << monthName[m-1] << " " << y << "." <<endl;
}//endif

&nbsp; getch();
&nbsp; return 0;
}//endmn

The Function


///////////////////////////////////////////////////////////////////////////
&nbsp; // // Pre:
// LeapYear //
// // Post:
//////////////
int LeapYear( int year )
{
&nbsp; if ( (year % 4 ==0 && year % 100 &#33;= 0) || year % 400 == 0 ) {
return 1;
}//endif
return 0;
}//endfn LeapYear

///////////////////////////////////////////////////////////////////////////
&nbsp; // &nbsp; // Pre:
// DayCount //
// &nbsp; // Post:
//////////////
int DayCount( int month )
{
&nbsp; if ( month >= 8 ) {
if ( month % 2 ) {
&nbsp; return 30;
}else{
&nbsp; return 31;
}//endif
&nbsp; }else{
if ( month % 2 ) {
&nbsp; return 31;
}else{
&nbsp; return 30;
}//endif
&nbsp; }//endif
}//endfn DayCount

And the Header, if this might help.


#ifndef _LEAPYEAR_H
#define _LEAPYEAR_H

int LeapYear( int year );
int DayCount( int month, int year );

#endif _LEAPYEAR_H


Anyone know how to get rid of that error?
Amarjit?

Damnatory
10-18-2003, 07:24 PM
Son of a..... Ok, I figured it out...

Duh&#33; I had an extra formal parameter in the header file function prototype.