C ++缺少类型说明符和未知的覆盖说明符 [英] C++ missing type specifier and unknown override specifier

查看:154
本文介绍了C ++缺少类型说明符和未知的覆盖说明符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了3个类

地图类

I have 3 classes that have been created
Map class

#ifndef MAP_H
#define MAP_H

#include "position.h"
#include "Entity.h"
#include <iostream>
#include <windows.h>
#include <ctime>
#include <iostream>

class Map
{
private:
	char mapSize[21][21];
public:
	Map();
	~Map();
};
#endif





实体类



Entity class

#ifndef ENTITY_H
#define ENTITY_H

#include "Map.h"

class Entity
{
	position pos;
public:
	Entity();
	~Entity();
};
#endif





职位等级



position class

#ifndef POSITION_H
#define POSITION_H

#include "Map.h"

class position
{
public:
	int x;
	int y;
	position();
	~position();
};

#endif





似乎错误的来源是来自entity.h,特别是行



It seems that the source of the error is from entity.h, specifically the line

position pos;





这些类在一起编译时给了我两个错误

1)C4430 - 缺少类型说明符 - 假设为int。注意:C ++不支持default-int

2)C3646 - 'pos':未知的覆盖说明符



我想知道是什么导致这个问题,因为我似乎无法弄清楚它是什么问题



我尝试了什么:



最初,在entity.h中我也包含了position.h,但我删除了它认为map.h导致了循环。显然不是。



FYI:



These classes, when compiled together, gives me two errors
1) C4430 - missing type specifier - int assumed. Note: C++ does not support default-int
2) C3646 - 'pos': unknown override specifier

I would like to know what is causing the issue, as I can't seem to figure out what the issue it

What I have tried:

Originally, in entity.h I had included position.h as well, but i removed it thinking that map.h was causing the loop. Apparently not.

FYI:

position pos;



之前是公开定义的,但它仍然无效


was defined in public before, but it still did not work

推荐答案

没有直接给你答案 - 想想每个类/头文件需要什么知道,所以课堂上的任何事情都需要了解班级地图。如果没有,那么不要包括map.h.在所有3个类定义上尝试这种推理。
Without giving you the answer directly - think about what each class / header file needs to "know about", so does anything in class position need to know about class map. If not then don't include map.h. Try this reasoning on all 3 class definitions.


在实体头文件中,您必须包含位置头以声明实体类成员的位置类。
In entity header file you must include the position header to declare the position class for the entity class member.


这篇关于C ++缺少类型说明符和未知的覆盖说明符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆