“日期”类的运用出错了
在下面这个程序中有一个错误,总是不能运行!#include <iostream>
using namespace std;
class Date
{
public:
Date();
Date (int y,int m,int d)
{ year=y;
month=m;
day=d;
cout<<"Constructor called!"<<endl;
}
~Date()
{ cout<<"Destructor called!"<<endl; }
void Date::set_date()
{ cin>>year>>month>>day; }
void display_date()
{ cout<<year<<" "<<month<<" "<<day<<endl; }
private:
int year;
int month;
int day;
};
int main()
{
Date d1;
d1.set_date();
Date d2(2014,3,27);
d1.display_date();
d2.display_date();
return 0;
}
Linking...
Date.obj : error LNK2001: unresolved external symbol "public: __thiscall Date::Date(void)" (??0Date@@QAE@XZ)
Debug/Date.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
Date.exe - 1 error(s), 0 warning(s)
请各位大神帮忙看看,小弟谢谢了!