[英]Including header files c++
i have an issue with including header files.我有包含头文件的问题。 In IObject i have error: "use of undefined type 'Button'"
在 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() {};
};
Button should either be forward declared or defined before using it.按钮应该在使用前预先声明或定义。
Check out Use of undefined type and When can I use a forward declaration?查看未定义类型的使用以及何时可以使用前向声明?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.