Main Index : Reference :

struct


Description

Declares a structure with all member functions and variables public.

Usage

struct struct_name
{
  member_unction(...);
  var member_variable;
  
  myStruct(...); // Constructor
}

struct_name::struct_name(...)
{
  // Constructor
}

struct_name::member_function(...)
{
  // Do something
}

Declaration

struct declares a C.O.F.F.E.E. structure. The only difference between a structure and a class is that in structures the default level of access is public:. Structures are often used to store several variables directly, and the variables can then be accessed directly without intermediary member functions. For information, see class.

Example

// These two declarations are the same:

struct myStruct
{
  var x,y;
}

class myStruct
{
public:
  var x,y;
}


// Using a structure:

function()
{
  var point = new(myStruct);
  
  point->x = 5;
  point->y = 6;
  
  // Outputs 5.
  println(point->x);
}

See Also

class, new()