【发布时间】:2015-06-13 18:23:35
【问题描述】:
我的私有变量 Player_player 出现错误;和级别_level;它告诉我它缺少类型说明符,我不确定这是为什么。我已经为Level和Player都做了类,所以我不应该能够使用Player和Level来指定变量类型吗?
感谢您的帮助,
麦克
//GameSystem.h
#pragma once
#include "Player.h"
#include "Level.h"
#include <string>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <conio.h>
#include <vector>
using namespace std;
class GameSystem
{
public:
GameSystem(string levelFileName);
void playGame();
private:
Level _level;
Player _player;
};
#
//播放器.h
#pragma once
#include "GameSystem.h"
#include "Level.h"
#include <string>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <conio.h>
#include <vector>
using namespace std;
class Player
{
public:
Player();
void initPlayer(int level, int health, int attack, int defense, int experience);
//Setters
void setPosition(int x, int y);
//Getters
void getPosition(int &x, int &y);
private:
//Properties
int _level;
int _health;
int _attack;
int _defense;
int _experience;
//Position
int _x;
int _y;
};
【问题讨论】:
-
能否请您附上完整的错误信息?
-
心理调试器说:递归标头。
-
错误 C2146:语法错误:缺少 ';'在标识符“_player”之前出现错误 C4430:缺少类型说明符 - 假定为 int。注意:C++ 不支持 default-int
-
请编辑问题以包含错误消息。这意味着
Player那时没有定义。没有看到 Player.h,我无法说出原因。 -
为什么 Player.h 需要包含 GameSystem.h?
标签: c++ class variables types ascii