Static variables, properties, and functions

Static variables, properties, and functions can be added in the same way that member variables, properties, and functions can. The function calls to do so are addStaticDataaddStaticPropertyand addStaticFunction.

The following code sample shows how to use all three of these functions:

class Vec3 {
public:
static Vec3 zero;

static Vec3 get_upvector() {
return Vec3(0, 1, 0);
}

static Vec3 Cross(Vec3 v1, Vec3 v2);
}

getGlobalNamespace(L)
.beginNamespace("Math")
.beginClass<Vec3>("Vec3")
.addStaticData("Zero", &Vec3::zero, false)
.addStaticProperty("Up", &Vec3::get_upvector)
.addStaticFunction("Cross", &Vec3::Cross)
.endClass()
.endNameSpace();
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.212.124