【发布时间】:2015-06-11 21:02:10
【问题描述】:
我遇到了三个我不明白的错误。第一个说:
"Player::Player()", referenced from:
Hangman::Hangman() in hangman.o.
第二个说:
"vtable for Hangman", referenced from:
Hangman::Hangman() in hangman.o
最后一句说:
Hangman::~Hangman() in main.o.
谁能帮帮我?
在我的头文件中,我有:
#ifndef PLAYER_H_
#define PLAYER_H_
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Player{
public:
Player();
char MakeGuess();
void Win();
void Lose();
char Agree();
private:
string name;
int score;
};
#endif
In my other headerfile I have
#ifndef HANGMAN_H_
#define HANGMAN_H_
#include <iostream>
#include <string>
#include <vector>
#include "player.h"
using namespace std;
class Hangman
{
public:
Hangman();
void Play();
protected:
Player player2;
vector<string> words;
int wrong;
const int maxwrong=4;
char guess;
void virtual RespondIncorrectGuess();
};
#endif
在我的主要功能中,我有一个不同的文件:
#include <iostream>
#include <string>
#include <vector>
#include "player.h"
#include "hangman.h"
using namespace std;
int main()
{
Hangman test;
test.Play();
}
【问题讨论】:
-
你需要include guards。
-
@CaptainObvlious 你的意思是 indef# 吗?我如何包括警卫
-
@CaptainObvlious 我进行了更改,但仍然出现错误。我在原始帖子中包含了错误消息
标签: c++ aggregation