小编Den*_*nis的帖子

使用直接Lua,如何公开现有的C++类目标以便在Lua脚本中使用?

我一直在使用C++嵌入Lua脚本的经验,我可以在这里使用.

考虑以下两个类:

// Person.hpp
#pragma once
#include <string>

class Person {
    private:
        std::string p_Name;
        int p_Age;

    public:
        Person(const std::string & strName, const int & intAge)
            : p_Name(strName), p_Age(intAge) { }

        Person() : p_Name(""), p_Age(0) { }

        std::string getName() const { return p_Name; }
        int getAge() const { return p_Age; }

        void setName(const std::string & strName) { p_Name = strName; }
        void setAge(const int & intAge) { p_Age = intAge; }
};
Run Code Online (Sandbox Code Playgroud)

......而且......

// PersonManager.hpp
#pragma once
#include "Person.hpp"
#include <vector> …
Run Code Online (Sandbox Code Playgroud)

c++ lua

7
推荐指数
1
解决办法
3603
查看次数

标签 统计

c++ ×1

lua ×1