I don’t understand what is wrong with this code. It says “incomplete type is not allowed for my function.”
This is what I’m trying to do:
Write a function named
yrClac()that has an integer parameter representing the total number of days since the turn of the century (1.1.2000) and reference parameters named year, month and day. The function is to calculate the current year, month and day for the given number of days passed to it. Using the references, the function should directly alter the respective actual arguments in the calling function. For this problem, assume that a year always has 365 days and every month has exactly 30 days.
#include <iostream>
using namespace std;
void yrClac(int total, int &a, int &b, int &c); // says incomplete type
// is not allowed
int main()
{
int totaldays;
cin >> totaldays;
int year = 2000, month = 1, day = 1;
void yrClac(totaldays, year, month, day);
cout << year << month << day;
system ("PAUSE");
return 0;
}
void yrClac(int total, int &a, int &b, int &c)
{
a = 365 / total;
b = total - a * 12;
c = total - b * 30;
}
You shouldn’t put the
void(aka the return type) when calling the function. Remove it invoid yrClac(totaldays, year, month, day);and it should work.