error C4430: 缺少类型说明符 - 假定为 int
来源:互联网 发布:域名被墙 301跳转 编辑:程序博客网 时间:2024/04/30 14:55
错误 1 error C2143: 语法错误 : 缺少“;”(在“*”的前面) e:\cocos2d-x-2.2.6\projects\mario\classes\layergame.h 14 1 Mario
错误 2 error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int e:\cocos2d-x-2.2.6\projects\mario\classes\layergame.h 14 1 Mario
ProgressBar.h
#ifndef __ProgressBar_H__#define __ProgressBar_H__#include "LayerStart.h"#include "Common.h"#include "LayerLevel.h"#include "LayerGame.h"class ProgressBar:public CCLayer{public: static ProgressBar* create(const char* backgroundFile,const char* foregroundFile); bool init(const char* backgroundFile,const char* foregroundFile); void setPercentage(float per); float getPercentage(); void setPosition(float x,float y);private: CCProgressTimer* _bar; CCSprite* _barBackground;};#endif // !__ProgressBar_H__
LayerGame.h
#ifndef __LayerGame_H__#define __LayerGame_H__#include "Common.h"#include "LayerStart.h"#include "LayerLevel.h"#include "ProgressBar.h"class ProgressBar;class LayerGame:public CCLayer{public: static LayerGame* create(int idx); bool init(int idx); void setBar(float dt); ProgressBar* _bar;};#endif // !__LayerGame_H__
如果删去class ProgressBar;就会出现文首的错误。检查发现是两个类的头文件ProgressBar.h与LayerGame.h互相包含,即在ProgressBar.h的文件中存在语句#include "LayerGame.h"
,在LayerGame.h的文件中存在语句#include "ProgressBar.h"
,且在LayerGame类中有ProgressBar类的对象ProgressBar* _bar
,这样就会出现文首的错误提示。
解决这类头文件互相包含问题时,可以在类的前面声明另外一个需要引用的类,即
class ProgressBar;class LayerGame:public CCLayer{ ProgressBar* _bar;}
参考资料:
http://blog.csdn.net/kennyrose/article/details/6049297
整理这类错误会出现的几种情况:
1. (此情况经常出现在大型工程项目中)如果存在两个类的头文件a.h和b.h,在a.h中有这样的语句:#include “b.h”,在b.h文件中有这样的语句:#include “a.h”且在一个类中有另一个类的对象时,那么就会出现这样的错误。
2. 没有包含要定义的类的头文件。
3.项目中少加了宏定义,导致头文件重复定义或相应宏无法识别。
4.当有多个头文件时,顺序写反也可能导致相关的错误,其根本是头文件中的预编译语句被隐去了。
5. 可能是函数没有写返回值
另外补充预编译宏的一些概念
#ifndef __LayerGame_H__//一般使用这种方式防止头文件在同一文件中被包含两次#define __LayerGame_H__#endif//!__LayerGame_H__
#define __LayerGame_H__
用define定义一个名字__LayerGame_H__
,当在下一次访问访问到该文件时,该名字已被定义,从而让程序跳过#ifndef…….#endif之间的语句。
- error C4430: 缺少类型说明符 - 假定为 int
- error C4430: 缺少类型说明符 - 假定为 int
- error C4430: 缺少类型说明符 - 假定为 int
- error C4430: 缺少类型说明符 - 假定为 int
- error C4430: 缺少类型说明符 - 假定为 int
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- afxwin1.inl(1014) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- ”error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int“ 解决办法
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- 【MFC BUG】error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认int 错误的解决方法
- vs2008编译遇到error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- Java概述
- 用POI导出数据到excel文件
- 数据结构—栈
- php开发日记之生成图片
- 数据分析——数据标准化
- error C4430: 缺少类型说明符 - 假定为 int
- 堆排序(C#)
- iOS 百度地图反编码地理位置信息
- SQLServer 里面的 DDL,DML,DCL,TCL
- freemarker循环遍历Map
- 汕头正宗的牛肉丸多少钱一斤的
- LeetCode---Spiral Matrix II
- Codeforces Round #327 (Div. 1) B题: Chip 'n Dale Rescue Rangers [数学题]
- 库函数strcpy/strlen的工作方式