-
Notifications
You must be signed in to change notification settings - Fork 0
Structs
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 the . operator:
b.member = 7;
The same can be done with functions:
b.Add(7);