C ++类名称未命名类型

时间:2015-11-13 13:47:24

标签: c++

#ifndef MAIN_H_INCLUDED
#define MAIN_H_INCLUDED
#include "Setup.h"
#include "mainCharacter.h"

class Main {

public:
    Main(int pScreenWidth, int pScreenHeight);
    ~Main();

void gameLoop();

private:
    bool quit;
    Setup* setup;

    mainCharacter* tom;

    int screenWidth;
    int screenHeight;

    int mouseX;
    int mouseY;
};
#endif // MAIN_H_INCLUDED

我在这看到了其他主题,但是我得到的错误不是同一类型,它怎么能告诉我

Setup* setup;
mainCharacter* tom;
当包含在上面时,

没有命名类型? 我使用code :: blocks如果重要的话。

编辑://////////////////////

这是安装程序标题:

#ifndef SETUP_H_INCLUDED
#define SETUP_H_INCLUDED

#include <SDL.h>
#include <SDL_image.h>
#include <SDL_mixer.h>

#include "Main.h"
#include "Sprite.h"

class Setup {

public:
    Setup(int screenWidth, int screenHeight);
    ~Setup();

    SDL_Renderer* getRenderer();
    SDL_Event* getEvent();

private:
    SDL_Window* window;
    SDL_Renderer* renderer;
    SDL_Event* event;
};

#endif // SETUP_H_INCLUDED

这是mainCharacter标题:

#ifndef MAINCHARACTER_H_INCLUDED
#define MAINCHARACTER_H_INCLUDED

#include "Sprite.h"
#include "Setup.h"
#include <cmath>

class mainCharacter {

public:
    mainCharacter(Setup* pSetup, int* pMouseX, int* pMouseY);
    ~mainCharacter();

    double getDistance(int x1, int y1, int x2, int y2);

    void update();
    void draw();

private:
    Sprite* shagy;

    ///some variables are here/////

    Setup* setup;
};

#endif // MAINCHARACTER_H_INCLUDED

有Setup.cpp和mainCharacter.cpp文件并且它们上面写了很长的代码,我在setup.cpp中包含的唯一内容是setup.h和maincharacter.cpp我只包含maincharacter.h

1 个答案:

答案 0 :(得分:0)

#ifndef SETUP_H_INCLUDED
#define SETUP_H_INCLUDED

确保您没有在其他地方定义SETUP_H_INCLUDED,这是我看到的唯一原因。

此外,%INCLUDE%(包含目录)可能在某处有另一个Setup.h,但未定义Setup类,并且未加载Setup.h