tags:

views:

132

answers:

1

I've got a Menu class which is a singleton. It is now going to have three Button objects on it, m_Load, m_Save, m_New. I am calling their constructors in an Init() method like so:

void Menu::Init()
{
    Menu::m_Load = new Button(L"../Data/png/load.png");
    Menu::m_Save = new Button(L"../Data/png/save.png");
    Menu::m_New = new Button(L"../Data/png/new.png");
}

And they are defined in the Menu.h file as

class Menu : public Singleton<Menu>
{
    friend class Singleton<Menu>;

//snip
private:
    Menu();
    Button m_Load;
    Button m_Save;
    Button m_New;
};

That Init method is giving the compiler error described in the title. How come?

+5  A: 

You're trying to assign a pointer to a Button to a Button. Declare your button members as pointers.

Button *m_Load;
nos