- 论坛徽章:
- 0
|
有三个文件, date.h date.cpp test.cpp, 链接时出现错误, 请高手帮忙. 代码如下,
test.cpp
#include "date.h"
int main(void)
{
DateTime dt;
dt.show();
return 0;
} |
date.h
#ifndef _TIME_H_
#define _TIME_H_
class DateTime {
public:
DateTime(void);
~DateTime(void);
void show(void);
private:
int date;
int time;
};
#endif |
date.cpp
#include "date.h"
#include <iostream>
using namespace std;
void DateTime::show(void)
{
cout << "Hello, world" << endl;
}
|
错误提示:
--------------------Configuration: test01 - Win32 Debug--------------------
Linking...
test01.obj : error LNK2001: unresolved external symbol "public: __thiscall DateTime::~DateTime(void)" (??1DateTime@@QAE@XZ)
test01.obj : error LNK2001: unresolved external symbol "public: __thiscall DateTime: ateTime(void)" (??0DateTime@@QAE@XZ)
Debug/test01.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
test01.exe - 3 error(s), 0 warning(s)
|
|
|