#include<iostream>
#include<ctime>
using namespace std;
class Date
{
public:
Date(int y,int m,int d);
void setDate(int y,int m,int d);
void setYear(int y);
void setMonth(int m);
void setDay(int d);
int getYear();
int getMonth();
int getDay();
void print();
private:
int year;
int month;
int day;
};
void Date::setYear(int y)
{
year=(y>0&&y<=2012?y:1);
}
void Date::setMonth(int m)
{
month=(m>0&&m<=12?m:1);
}
void Date::setDay(int d)
{
day=(d>0&&d<=31?d:1);
}
void Date::setDate(int y,int m,int d)
{
setYear(y);
setMonth(m);
setDay(d);
}
int Date::getYear()
{
return year;
}
int Date::getMonth()
{
return month;
}
int Date::getDay()
{
return day;
}
void Date::print()
{
cout<<year<<" "<<month<<" "<<day<<endl;
}
int main()
{
int y,m,d;
cout<<"请输入年月日:";
cin>>y>>m>>d;
Date now(y,m,d);
cout<<"用户设置的时间是";
now.print();
return 0;
}
compile时没错build时有两个错error LNK2001: unresolved external symbol "public: __thiscall Date::Date(int,int,int)" 和Debug/dddd.exe : fatal error LNK1120: 1 unresolved externals
再次说声谢谢!
#include<ctime>
using namespace std;
class Date
{
public:
Date(int y,int m,int d);
void setDate(int y,int m,int d);
void setYear(int y);
void setMonth(int m);
void setDay(int d);
int getYear();
int getMonth();
int getDay();
void print();
private:
int year;
int month;
int day;
};
void Date::setYear(int y)
{
year=(y>0&&y<=2012?y:1);
}
void Date::setMonth(int m)
{
month=(m>0&&m<=12?m:1);
}
void Date::setDay(int d)
{
day=(d>0&&d<=31?d:1);
}
void Date::setDate(int y,int m,int d)
{
setYear(y);
setMonth(m);
setDay(d);
}
int Date::getYear()
{
return year;
}
int Date::getMonth()
{
return month;
}
int Date::getDay()
{
return day;
}
void Date::print()
{
cout<<year<<" "<<month<<" "<<day<<endl;
}
int main()
{
int y,m,d;
cout<<"请输入年月日:";
cin>>y>>m>>d;
Date now(y,m,d);
cout<<"用户设置的时间是";
now.print();
return 0;
}
compile时没错build时有两个错error LNK2001: unresolved external symbol "public: __thiscall Date::Date(int,int,int)" 和Debug/dddd.exe : fatal error LNK1120: 1 unresolved externals
再次说声谢谢!