binary '=': no operator found which takes a right-hand operand of type "Button *"
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 giv开发者_开发知识库ing the compiler error described in the title. How come?
You're trying to assign a pointer to a Button to a Button. Declare your button members as pointers.
Button *m_Load;
精彩评论