2017-12-12 2 views
-1

프로젝트 용 Windows 콘솔 rpg를 만들고 있는데, 부모 클래스를 상속 한 클래스를 변경하고 개체를 가져 와서 부모 클래스 두 개를 상속 받으면 실행할 때 문제가 발생합니다. 이제 두 번째 기본 클래스가 정의되지로
헤더 클래스는여러 부모로부터 상속받은 자식 클래스 C++

#include "GameObject.h" 
    #include "BattleObject.h" 
    #include "Player.h" 
    #include "Weapon.h" 
    #include <string> 
    #include <vector> 
using namespace std; 
class Monster : 
    public GameObject, 
    public BattleObject 
{ 
private : 
    string m_name; 
    vector<string> m_drops; 

public: 
    Monster(std::pair<int, int> coordinates, string name, vector<string> drops, int health, int attack, int defence); 
    string getName(); 

}; 

아래는 나는이 개 기본 클래스에 걸릴 것으로 예상하지만, 그것 때문에 충돌하고 다음과 같이 말한다이

의 실행되지 않습니다 Battle Object 기본 클래스가 정의되지 않았습니다.

+0

_it 충돌과와 전투 개체의 기본 클래스는 undefined_ 사본입니다 및 메시지를 붙여 말한다. –

+1

헤더에'using namespace std'를 넣으시겠습니까? 와우, 그러고 싶지 않다. – UKMonkey

+0

BattleObject에 인수가없는 생성자가 있습니까? 그렇다면 정의되어 있습니까? –

답변

0

아마 당신은 명시 적으로 어쩌면 그들이 암시 생성자가없는 각각의 base class의 적절한 생성자를 호출해야합니다

Monster(...) : GameObject(...), BattleObject(...) { ... } 
관련 문제