包括头文件c ++

时间:2016-09-15 13:47:24

标签: c++ header undefined

我遇到包含头文件的问题。 在IObject我有错误: "使用未定义的类型'按钮'"

    //IObject.h
#pragma once
#include "Button.h"

struct IObject
{
    void SendToMenu(Button sender) //ERROR
    {
        switch (menu_type)
        {
        case menu::game:
            Game.AllButtons.push_back(&sender);
            break;
        }
    }
};

#pragma once
#include "ButtonEvent.h"

class Button sealed : public IObject
{
public:

    Button(Vector2f position, Vector2f size, string button_value, Color text_color, Color normal_color, Color pressed_color, menu menu_type)
    {
        this->position = position;
        this->size = size;
        this->button_value = button_value;
        this->button_color = normal_color;
        this->text_color = text_color;
        this->active_background_color = pressed_color;
        this->normal_background_color = normal_color;
        this->ID = buttons.size() > 0 ? buttons.size() : 0;
        this->menu_type = menu_type;

        SendToMenu(*this);

        buttons.push_back(*this);
    }

    ~Button() {};
};

1 个答案:

答案 0 :(得分:0)

按钮应该在使用之前进行前向声明或定义。

结帐Use of undefined typeWhen can I use a forward declaration?