🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

class polymorphism in LUA

Started by
10 comments, last by nekoflux 20 years, 3 months ago
Lua in combination with Luabind doesn''t really need the idea of a C++ base class. Don''t forget that in luabind you can try to call a method of an object which may or may not be there, but that method is *always* looked up a run-time.

Effectively Lua objects always exhibit virtual behavior, you can think of this as being similar to the concept of a vtable in C++, but rather than having a pointer based table, you''re dispatching to a function based on the name.

I''ve run the snippets that you''ve given in VC6 SP5 and VC7 and it builds (and runs) fine in both. Like Sneftel and Dew_LED I''m guessing that the problem''s with something else.
Advertisement
I fixed it. It was a combination of several things:

1) it didnt like the new operator, and the semicolons at the end were unneccessary

2) I had to declare the classes as extending the base class within the module definition. Heres the modue defines that accomplish this:

module(L)[	class_<CMyBaseClass>("CMyBaseClass"),	class_<CBox, CMyBaseClass>("CBox")        //register the virtual functions here for CBox,        class_<CSphere, CMyBaseClass>("CSphere")        //register the virtual functions here for CSphere]; 



Hope this helps someone in the future

thanks for all your help in previous posts, as usual my scriptin' homies came through for me


neko

[edited by - nekoflux on April 1, 2004 12:50:49 PM]
nekoflux

This topic is closed to new replies.

Advertisement