C++ 什么';这里怎么了ISO C&x2B+;禁止声明';圆圈';没有类型

C++ 什么';这里怎么了ISO C&x2B+;禁止声明';圆圈';没有类型,c++,class,iso,C++,Class,Iso,也许你能帮我搞定。 我有一个用来画圆的类,但编译器向我发送了以下消息: In file included from ./Includes.h:19, from ./Circle.h:8, from ./Circle.cpp:5: ./GameApp.h:24: error: ISO C++ forbids declaration of 'Circle' with no type ./GameApp.h:24: error: ex

也许你能帮我搞定。 我有一个用来画圆的类,但编译器向我发送了以下消息:

In file included from ./Includes.h:19,
                 from ./Circle.h:8,
                 from ./Circle.cpp:5:
./GameApp.h:24: error: ISO C++ forbids declaration of 'Circle' with no type
./GameApp.h:24: error: expected ';' before '*' token
这是GameApp.h:

#include "Includes.h"

class GameApp {

public:
 GameApp();
 ~GameApp();
 void Render();

protected:
 void InitGU();
 bool Controls();

 void *dList;  // display List, used by sceGUStart
 void *fbp0;  // frame buffer

 Circle* circle;
};
Include.h如下所示:

//************************************************************************
//                              Includes.h
//************************************************************************

#include <malloc.h>     //For memalign()
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <stdio.h>
#include <psprtc.h>             // for the timer/fps functions
#include <pspctrl.h>
#include <math.h>

// GU
#include <pspgu.h>
#include <pspgum.h>

// Custom
#include "GameApp.h"
#include "Circle.h"


//************************************************************************

// Definitions
#define BUF_WIDTH (512)
#define SCR_WIDTH (480)
#define SCR_HEIGHT (272)

#define sin_d(x) (sin((x)*M_PI/180))
#define cos_d(x) (cos((x)*M_PI/180))
#define tan_d(x) (tan((x)*M_PI/180)) 

//************************************************************************

// structs, datatypes...
#ifndef VERTEX_TYPE_
#define VERTEX_TYPE_
typedef struct {
    unsigned int color;
    float x, y, z;
} vertex;
#endif

你可能有循环包含。使用转发声明:

class GameApp { 
class Cicle;
...

我会检查make文件以确保构建的顺序正确,然后在每个.h文件中都包含.h,如果两个类都很简单,请尝试合并该类。祝你好运

不要使用一个大规模包含来包含所有内容(预编译头除外)。这几乎肯定会导致头痛

包括你需要的,不要更多。它会解决你的问题


您可以将
Circle
声明为转发,但从长远来看,解决包含问题将对您有更大帮助。

包含.h在包含Circle.h之前包含GameApp.h。因此,Circle在第一次遇到GameApp的定义时还没有定义。正如丹丹所说的那样,向前声明Circle。

@James是对的——Circle.h#包括GameApp.h,如原始编译器消息所示,而GameApp.h#包括Circle.h是通过考虑不周的“include all”include.h来实现的,但由于include.h中存在冗余的include防护,include是无用的,您需要将
#include“Circle.h”
移动到
#include“GameApp.h”
之前。更好的是,直接从GameApp.h中包含Circle.h。每个头文件都应该包含它需要直接编译的所有内容。

我删除了C标记。在这样的问题上加C完全是荒谬的。而且,这门课也没什么问题。查看实际代码会很有用。Includes.h中是否包含GameApp.h?你的标题有包含保护吗?是否存在循环包含问题?是否确定Circle.h是有效的头文件?是否使用它成功编译了某些内容?也许您忘记了类声明末尾的分号了?至少可以看到包含
圆圈
类定义的代码。请发布Circle.h。并在任何包含文件中查找不匹配的}。对于include.h中的“defines”或vertex的类型定义,您会怎么说?您刚刚在GameApp中将声明的类Cicle[sic]作为嵌套类转发。然后,编译器将查找GameApp::Cicle类的实现。转发声明应在GameApp定义之外(或之前)。
class GameApp { 
class Cicle;
...