我正在尝试制作一些Monopoly游戏来练习我的C ++技能,但是我遇到了诸如“未声明的标识符”之类的错误,以及许多其他似乎表明我的#includes无法正常工作的错误。我正在使用Visual Studio 2017。
我已经删除了所有不必要的代码,这很简单,但是我仍然找不到问题所在。
有五个小文件。
main.cpp
data temp;
set have;
by id;
if first.id then count=1;
else count+1;
run;
Player.h
#include "Player.h"
#include "Property.h"
int main() {
return 0;
}
Property.h
#pragma once
#ifndef PLAYER_H
#define PLAYER_H
#include <vector>
#include "Property.h"
using namespace std;
class Player {
public:
vector<Property*> getProperties(); // line 12
private:
vector<Property*> properties_; // line 15
};
#endif
Player.cpp
#pragma once
#ifndef PROPERTY_H
#define PROPERTY_H
#include "Player.h"
using namespace std;
class Property { // line 12
public:
Player* getOwner(); // line 14
protected:
Player* owner_;
};
#endif
Property.cpp
#include "Player.h"
vector<Property*> Player::getProperties()
{
return properties_;
}
这是编译时遇到的错误。我只保留了说明,文件和行以使其更具可读性。
#include "Property.h"
Player * Property::getOwner()
{
return owner_;
}
在此先感谢您的帮助!