fatal error LNK1120: 1 unresolved externals 如何解决这个问题?
jibee 2008-03-30 11:32:54 #ifndef HEAD_H
#define HEAD_H
class Date {
public:
Date ( int = 1 , int = 1, int = 1990 );
void print() const;
~Date();
private:
int month;
int day;
int year;
int checkDay( int ) const;
};
#endif
#include <iostream>
using std::cout;
using std::endl;
#include "head.h"
Date::Date( int mn, int dy, int yr)
{
if ( mn > 0 && mn <=12 )
month = mn;
else {
month = 1;
cout << "Month " << mn << " invalid. Set to month 1.\n";
}
year = yr;
day = checkDay ( dy );
cout << "Date object constructor for date ";
print ();
cout << endl;
}
void Date::print() const
{
const char *monptr[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
cout << monptr[month-1] <<" " << year << endl;
cout << month << '/' << day << '/' << year <<endl;
cout << monptr[month-1] << " " << day << ',' << " " << year <<endl;
}
Date::~Date()
{
cout << "Date object destructor for date ";
print();
cout <<endl;
}
int Date::checkDay ( int testDay ) const
{
const int daysPerMonth[ 13 ] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if ( testDay > 0 && testDay <= daysPerMonth[ month ] )
return testDay;
if ( month == 2 && testDay == 29 && ( year % 400 == 0 || ( (year % 4 == 0) && (year % 100 != 0))))
return testDay;
cout << "Day " << testDay << " invalid. Set to day 1.\n";
return 1;
}