-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Integrate Lua with C++
By :

In Chapter 2, Lua Fundamentals, we learned about the Lua types. They are different from C++ types. To use them in C++, we need to do some mapping. In Chapter 3, How to Call Lua from C++, we mapped the Lua string to the C++ std::string
. It is mapped by hardcoding it in our Lua executor.
What if we want to support all possible Lua types, both in the function arguments and in function return values? What if we want to call Lua functions with different numbers of arguments? It is not feasible to create a C++ function for each argument type and argument count combination. That way, our Lua executor would be plagued with hundreds of functions just to call Lua functions!
Fortunately, C++ is powerful with its object-oriented programming and its generic programming. These two paradigms lead to two different ways in which you can solve problems in C++.
As said, C++ supports object-oriented programming and generic programming....