![]() |
#2
rjsp2011-12-10 08:16
|
两个文件为什么连不起来??

文件1
# include<iostream.h>
# include"tdate.h"
void main()
{
Tdate s;
s.Set(12/9/2011);
someFunc(&s);
}
void someFunc(Tdate * pS)
{
pS->Print();
if (pS->IsLeapYear())
cout<<"ohoh\n";
else
cout<<"right\n";
}
文件2
# include<iostream.h>
class Tdate
{
public:
void Set(int m,int d,int y)
{
month=m;
day=d;
year=y;
}
int IsLeapYear()
{
return (year%4==0&&year%100!=0)||(year%400==0);
}
void Print()
{
cout<<month<<"/"<<day<<"/"<<year<<"\n";
}
private:
int month;
int day;
int year;
};
错误提示:
C:\Users\Administrator\Desktop\c++\2.cpp(2) : fatal error C1083: Cannot open include file: 'tdate.h': No such file or directory
# include<iostream.h>
# include"tdate.h"
void main()
{
Tdate s;
s.Set(12/9/2011);
someFunc(&s);
}
void someFunc(Tdate * pS)
{
pS->Print();
if (pS->IsLeapYear())
cout<<"ohoh\n";
else
cout<<"right\n";
}
文件2
# include<iostream.h>
class Tdate
{
public:
void Set(int m,int d,int y)
{
month=m;
day=d;
year=y;
}
int IsLeapYear()
{
return (year%4==0&&year%100!=0)||(year%400==0);
}
void Print()
{
cout<<month<<"/"<<day<<"/"<<year<<"\n";
}
private:
int month;
int day;
int year;
};
错误提示:
C:\Users\Administrator\Desktop\c++\2.cpp(2) : fatal error C1083: Cannot open include file: 'tdate.h': No such file or directory