|
-- Hello, -- Lua equivalent to C++: -- #include <iostream> -- struct C { void m() { std::cout << "C::m()" <<
std::endl; } }; -- struct D : C { -- void m() { -- C::m(); // base class -- std::cout << "D::m()"
<< std::endl; -- } -- }; -- int main() { D d; d.m(); return 0; } C = { } function C:new( o ) o = o or { } setmetatable(o, self) self.__index = self return o end function C:m() print("C:m()") end D = C:new{} function D:m() C.m( self ) -- no better OO-like syntax available ? like
:C:m() for example ? print("D:m()") -– I’d like to clearly express
this is different from call to external function end |