   LuaBind polymorphism
  Hey guys,I've been having some problems using polymorphism with luabind, here's the situation: I have an abstract Control class representing a GUI element and 2 concrete subclasses, Dialog and Button. Control has a method attach(Control* child) for nesting controls within eachother. So you can add Buttons to a Dialog, say.I export them to a LUA state with the following code:    // Export Controls    luabind::module(vm) [    luabind::class_<Control>("Control")   .def("attach", &Control::attach)   //..    ];   luabind::module(vm) [    luabind::class_<Dialog, Control>("Dialog")   .def(luabind::constructor<>())   //..    ];   luabind::module(vm) [    luabind::class_<Button, Control>("Button")   .def(luabind::constructor<std::string>())   //..    ];So far so good. The problem happens in the LUA script when I try to call Control::attach(Control*) with a derived type:menu = Dialog()newGameButton = Button("New Game")exitButton = Button("Exit")menu.attach(newGameButton)This results in the error messageNo matching overload found, candidates:void attach(Control&,Control*)Can anyone give an example of how to do this properly? I've done a lot of searching and can't find a whole lot of good info about luabind except for the official docs and the tutorial at http://www.nuclex.org/articles/cxx/1-quick-introduction-to-luabind so any help would be much appreciated.Thanks, Matt   
  One of the interesting bits of lua table syntax is how to call member functions.The . operator is simple indexing, so if you had a function SomeTable.doStuff(self, arg) ... and did tableInstance.doStuff(1); that would call doStuff(1, nil). If the function expects self to be a table instance; you explode and die. The proper way to do calls like that is to explicitly pass the self parameter, so you'd have to do tableInstance.doStuff(tableInstance, 1). Lua does, however, offer a shortcut with the : operator. So that when you do tableInstance:doStuff(1), it calls doStuff(tableInstance, 1).Uh; anyway. The answer is to do menu:attach(...). Just make sure you're consistent with your operators.   ;  Thanks for the explanation, it's working. So the colon operator is a shortcut for passing a pointer to the instance as the first argument. Can't believe I missed that, I was using : in all the rest of the scriptCheers   