-3

i have an issue with including header files. In IObject i have error: "use of undefined type 'Button'"

    //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() {};
};
Pete Becker
  • 74,985
  • 8
  • 76
  • 165
sadsad
  • 1
  • 1
  • 1
    please put your code in a clear and stripped down version inline in the question. Also in regards to this: http://stackoverflow.com/help/mcve – Hayt Sep 15 '16 at 13:51

1 Answers1

0

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?

Community
  • 1
  • 1
Jerin Joseph
  • 1,087
  • 9
  • 17
  • I catn forward delcare. I use those headers in main program and it can't be forward declared because in all cases there will be problem with undefined class, i find a way to synchronize this. PS. sorry for edit, i was thinking that was my answer..... – sadsad Sep 15 '16 at 14:02