Skip to content
Matthew edited this page Dec 22, 2016 · 5 revisions

A structure is an object that can contain member variables and functions. This functions much like a class in C++ would and can inherit from other classes. The main difference between structs in Jet and C++ is that every member function defaults to being 'virtual'. Every member has public visibility.

An example struct in jet:

struct A
{
    int member;

    fun void Add(int num)
    {
        this->member += num;
    }
}

You can then instantiate such a struct in your code, either with constructor syntax, or by specifying the type in a let statement:

let A b;

or

let b = A();

accessing members can be done using .:

b.member = 7;

same with functions

b.Add(7);
Clone this wiki locally