请看下面的代码
主文件
#include <iostream>
#include <string>
using namespace std;
int main()
{
system("pause");
return 0;
}
魔法.h
#pragma once
class Magic
{
public:
Magic();
~Magic();
virtual void display()=0;
};
拼写.h
#pragma once
#include "Magic.h"
#include <iostream>
#include <string>
using namespace std;
class Spell :
public Magic
{
public:
Spell(void);
Spell(string words);
~Spell(void);
void display();
private:
string words;
};
拼写.cpp
#include "Spell.h"
#include "Magic.h"
#include <iostream>
#include <string>
using namespace std;
Spell::Spell(void)
{
}
Spell::Spell(string words)
{
this->words = words;
}
Spell::~Spell(void)
{
cout << "Delete Spell" << endl;
}
void Spell::display()
{
cout << "Spell Words: " << words << endl;
}
在这里,我收到错误
1>------ Build started: Project: Revision1_1, Configuration: Debug Win32 ------
1>Spell.obj : error LNK2019: unresolved external symbol "public: __thiscall Magic::~Magic(void)" (??1Magic@@QAE@XZ) referenced in function __unwindfunclet$??0Spell@@QAE@XZ$0
1>Spell.obj : error LNK2019: unresolved external symbol "public: __thiscall Magic::Magic(void)" (??0Magic@@QAE@XZ) referenced in function "public: __thiscall Spell::Spell(void)" (??0Spell@@QAE@XZ)
1>C:\Users\yohan\Documents\Visual Studio 2010\Projects\Revision1_1\Debug\Revision1_1.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我不明白在这里做什么。为什么会这样?请帮忙!反正我是 C++ 新手..