我老是忘记上课,所以编写了一个程序,可以有时候看看这个星期是第几周,有什么任务要交,方便一下自己,结果出现下面错误,请指教
错误提示如下:
--------------------Configuration: Noname2 - Win32 Debug--------------------
Compiling...
Noname2.cpp
D:\Documents and Settings\Administrator\桌面\王飞\查询课程第几周\Noname2.cpp(12) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Error executing cl.exe.
程序源码如下:
#include <iostream>
using namespace std;
class Date
{
int ye,mo,da;
int m[12];
bool isLeapYear(int num){return (num%400==0)||((num%4==0)&&(num%100!=0));}
public:
Date(int c,int a,int b):ye(c),mo(a),da(b){m[]={31,28,31,30,31,30,31,31,30,31,30,31};if(isLeapYear(c))m[1]=29;}
friend int operator-(Date m,Date n)
{
int total=0;
for(int i=m.mo-1;i<n.mo;i++)all+=m[i];
all+(n.da-m.da);
return total;
}
friend int weekth(Date &m,Date &n)
{
int days=n-m;
return days/7+1;
}
};
int main()
{
ifstream ins("date.txt");
int y1,y2,m1,m2,d1,d2;
if(!ins)
{
do
{
cout<<"输入开学日期(月,日):";
cin>>setw(4)>>y1>>setw(2)>>m1>>setw(2)>>d1;
if(y1<=2005||y1>=2008||m1<=0||m1>=13||da<=0||da>=31)continue;
ofstream ous("date.txt");
ous<<y1<<" "<<m1<<" "<<d1;
ous.close();
}while(y1<=2005||y1>=2008||m1<=0||m1>=13||da<=0||da>=31);
}
else
{
ins>>y1>>m1>>d1;ins.close();
}
Date term(y1,m1,d1);
cout<<"输入今天的日期";
cin>>setw(2)>>m2>>setw(2)>>d2;
Date now(y2,m2,d2);
int weekth=weekth(term,now);
cout<<"今天是第 "<<weekth<<"周"<<endl;
system("pause");
return 0;
}