簡體   English   中英

包括頭文件 c++

[英]Including header files c++

我有包含頭文件的問題。 在 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() {};
};

按鈕應該在使用前預先聲明或定義。

查看未定義類型的使用以及何時可以使用前向聲明?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM