瀏覽代碼

examples: Improve stack example

Ole Krüger 10 年之前
父節點
當前提交
5143a2e4d7
共有 1 個文件被更改,包括 6 次插入6 次删除
  1. 6 6
      examples/stack.cpp

+ 6 - 6
examples/stack.cpp

@@ -6,8 +6,8 @@
 using namespace luwra;
 
 static
-lua_Integer sum3(lua_Integer a, lua_Integer b, lua_Integer c) {
-	return a + b + c;
+double sum3(int a, int b, double c) {
+	return (a + b) * c;
 }
 
 int main() {
@@ -17,12 +17,12 @@ int main() {
 	// Build stack
 	lua_pushinteger(state, 13);
 	lua_pushinteger(state, 37);
-	lua_pushinteger(state, 42);
+	lua_pushnumber(state, 42);
 
 	// Each value can be retrieved individually.
-	std::cout << "a = " << Value<lua_Integer>::read(state, 1) << std::endl;
-	std::cout << "b = " << Value<lua_Integer>::read(state, 2) << std::endl;
-	std::cout << "c = " << Value<lua_Integer>::read(state, 3) << std::endl;
+	std::cout << "a = " << Value<int>::read(state, 1) << std::endl;
+	std::cout << "b = " << Value<int>::read(state, 2) << std::endl;
+	std::cout << "c = " << Value<double>::read(state, 3) << std::endl;
 
 	// ... which is a little cumbersome. Instead we might apply a fitting function to our stack.
 	std::cout << "a + b + c = "