Re: how to derive lua class from c++ class
David Osipyan <[email protected]> Sun, 8 Jan 2012 21:42:25 +0400
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <CAKpVfKF22xGrxp5SW_ZmvLs5y40EbqDMYX9PG-wM6XGwEp-8eQ@mail.gmail.com> |
Hi, Here is a good sample http://forums.tigsource.com/index.php?topic=3149.0 Best, David 2012/1/8 kunshou <[email protected]> > ** ** > > ** ** > > *发件人:* kunshou [mailto:[email protected]] > *发送时间:* 2012年1月2日 2:24 > *收件人:* [email protected] > *主题:* how to derive lua class from c++ class**** > > ** ** > > Hi**** > > I just stepped into luabind 0.9.1. I am trying to derive a class in lua > from a c++ class.**** > > My c++ class looks like**** > > class testclass**** > > {**** > > public:**** > > testclass(const char* s): m_string(s) **** > > {std::cout << m_string << " @created." << std::endl;}**** > > void print_string() { std::cout <<"testclass:" <<m_string << "\n"; }** > ** > > ** ** > > private:**** > > std::string m_string;**** > > };**** > > ** ** > > The lua code**** > > ** ** > > class 'derivedclass' (testclass)**** > > function derivedclass:__init(name)**** > > testclass:__init(name);**** > > end**** > > ** ** > > testderivedclass = derivedclass("hi")**** > > testderivedclass:print_string()**** > > ** ** > > when I run this lua code in c++ using luaL_dofile, the program always > crashes.**** > > ** ** > > Could anyone please tell what’s wrong with my code, or give a right > example?**** > > ** ** > > Many thanks**** > > > ------------------------------------------------------------------------------ > Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex > infrastructure or vast IT resources to deliver seamless, secure access to > virtual desktops. With this all-in-one solution, easily deploy virtual > desktops for less than the cost of PCs and save 60% on VDI infrastructure > costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox > _______________________________________________ > luabind-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/luabind-user > > ------------------------------------------------------------------------------ Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex infrastructure or vast IT resources to deliver seamless, secure access to virtual desktops. With this all-in-one solution, easily deploy virtual desktops for less than the cost of PCs and save 60% on VDI infrastructure costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox _______________________________________________ luabind-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luabind-user