如何在tc3.0中建立多文件工程在编译不出错
//leapyear.cpp
# include <iostream.h>
# include "tdate.h"
void someFunc(Tdate * ps)
{
ps->Print();
if (ps->IsLeapYear())
cout<<"leap year\n";
else
cout<<"not leap year\n";
}
void main()
{ Tdate s;
s.Set(2,15,1998);
someFunc(&s);
}
// tdate.h
class Tdate
{
public:
void Set(int,int,int);
int IsLeapYear();
void Print();
private:
int month;
int day;
int year;
};
// tdate.cpp
#include <iostream.h>
#include "tdate.h"
void Tdate::Set(int m,int d,int y)
{
month=m;
day =d;
year=y;
}
int Tdate::IsLeapYear()
{
return (year % 4==0&&year % 100 !=0)||(year % 400 ==0);
}
void Tdate::Print()
{
cout<<month<<"/"<<day<<"/"<<year<<endl;
}
// leapyear .prj
leapyear.cpp
tdate.cpp