我不明白这段代码有什么问题。它说“我的功能不允许使用不完整的类型”。
这就是我想要做的:
编写一个名为的函数
yrClac()
,它有一个整数参数,表示自世纪之交 (1.1.2000) 以来的总天数,以及名为年、月和日的引用参数。该函数用于计算传递给它的给定天数的当前年、月和日。使用引用,函数应该直接改变调用函数中各自的实际参数。对于这个问题,假设一年总是有 365 天,而每个月正好有 30 天。
#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;
}