function does not take 0 arguments

Hey I'm trying to compile my program, but I cannot figure out this compile error, I've spent almost 2 hours now trying to figure it out.

Heres the code :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
 # include <iostream>

using namespace std;

void getDate ();
void printDate (int, int, int );
int dayNumber (int, int, int);
bool validDate (int, int, int);
bool isLeapYear (int);

void main ()
{

  cout << "This program will ask for a date and then return it in a different format" << endl;
  
   getDate ();


return ;
}

void getDate ()
{

  bool valid;
  int month;
  int day;
  int year;
  char slash1;
  char slash2;
  
  
  
  cout << "Please enter the date in the form of mm/dd/yyyy:           "<< endl;
  cin >> month >> slash1 >> day >> slash2 >> year;


  valid = validDate( month, day, year);  
  
  if (valid == false)
   { 
    cout << " Date is invalid, please enter a year 1 - 3000 only, with a correct month and day in the form of mm/dd/yyyy: " << endl;
    cin >> month >> slash1 >> day >> slash2 >> year;
   }
  
  
  printDate( month, day, year);


}

void printDate( int printMonth, int printDay, int printYear)
{

 int daynum; 

 switch (printMonth)
 {
  case 1:

    cout << printDay << "-January-" << printYear << endl;

    break;

  case 2:

    cout << printDay << "-February-" << printYear << endl;

    break;

  case 3:

    cout << printDay << "-March-" << printYear << endl;

    break;

  case 4:

    cout << printDay << "-April-" << printYear << endl;

    break;

  case 5:
   
    cout << printDay << "-May-" << printYear << endl;

    break;

  case 6:

    cout << printDay << "-June-" << printYear << endl;

    break;

  case 7:

    cout << printDay << "-July-" << printYear << endl;

    break;

  case 8:

    cout << printDay << "-August-" << printYear << endl;
    break;

  case 9:

    cout << printDay << "-September-" << printYear << endl;

    break;

  case 10:

    cout << printDay << "-October-" << printYear << endl;

    break;

  case 11:

    cout << printDay << "-November-" << printYear << endl;
 
    break;

  case 12:

    cout << printDay << "-December-" << printYear << endl;

    break;
 }
   
 daynum =  dayNumber( printMonth, printDay, printYear);
  
 cout <<" is day number " << daynum  << " in " << printYear << endl;

}

int dayNumber ( int month, int day, int year )
{
 int dayNum2;
 int leapDay;
 leapDay = 31;
 bool leapYear;

 leapYear = isLeapYear(int year);

if ( leapYear == true)
 leapDay = 32;


 switch (month)
  {
   case 1:
  
    dayNum2 = day;
  
    break;

   case 2:

    dayNum2 = leapDay + day;

    break;    

   case 3:

    dayNum2 = 59 + day;

    break;

   case 4:

    dayNum2 = 90 + day;

    break;

   case 5:

    dayNum2 = 120 + day;

    break;

   case 6:

    dayNum2 = 151 + day;

    break;

   case 7:

    dayNum2 = 181 + day;

    break;

   case 8:

    dayNum2 = 212 + day;

    break;

   case 9:

    dayNum2 = 243 + day;

    break;

   case 10:

    dayNum2 = 273 + day;

    break;

   case 11:

    dayNum2 = 304 + day;

    break;

   case 12:

    dayNum2 = 334 + day;

    break;

 }
return dayNum2;
}

bool validDate (int day, int month, int year)
 {

  int leapDay;
  leapDay = 28;
  bool leapYear;

leapYear = isLeapYear( int year );

if (leapYear == true)
 leapDay = 29;

 if ( year >= 1 & year <= 3000)
{
    if (month >=1 & month <= 12)
     {
       if (month == 2)
        {
         if (day >= 1 & day <= leapDay)
          return true;
         else
          return false;
        }
       else if ( month == 1 || month == 3 || month == 5 || month == 7 || month  == 8 || month == 10 || month == 12)
        {
         if ( day >= 1 & day <= 31)
          return true;
         else
          return false;
        }
       else
        {
         if ( day >= 1 & day <= 30 )
          return true;
         else
          return false;
        }
       }
    else
     return false;
   }
 else
  return false;
 }        

bool isLeapYear(int year)
 {

  if ( year % 100 == 0)
   {
    if ( year % 400 == 0)
     return true;
    else
     return false;
   }

  else if ( year % 4 == 0 )
   return true;
  else
  return false;

 }


And heres the error I get-

syntax error : 'int' should be preceded by ')'

error C2660: 'isLeapYear' : function does not take 0 arguments

error C2059: syntax error : ')'

error C2144: syntax error : 'int' should be preceded by ')'

error C2660: 'isLeapYear' : function does not take 0 arguments

error C2059: syntax error : ')'

I encounter the "function does not take 0 arguments" error before, but it was with void functions, I dont understand why its happening with a bool function.
Any help would be appreciated and thanks in advance.
FYI: The error you are getting is because you are not passing arguments to a function that it wants, or you are passing too many. It has nothing to do with the return type of the function.

I believe the error is on line 235 leapYear = isLeapYear( int year );

I think you meant leapYear = isLeapYear( year );

EDIT: What are you talking about? I said 235 all along XP
Last edited on
You mean line 235 :)
Topic archived. No new replies allowed.