Main Index : Reference :
[object,array,string,bytes] new([class] class, ...)
class
is the name of the class to be allocated....
is one or many parameters separated by commas.
new()
is the universal allocation function in C.O.F.F.E.E. It allocates an instance of class
and passes any additional parameters to the object's constructor. The new()
command is used both for classes and structures and for strings, arrays and byte arrays. It returns a reference to the allocated object.
// Allocates a string of length 5.
var str = new(string,5);
// Allocates a two-dimensional array of 6 x 7.
var a = new(array,6,7);
// Allocates a byte array of length 8.
var mem = new(bytes,8);
// Allocates an instance of the structure Complex
// with real=3 and imag=5.
struct Complex
{
var real,imag;
Complex(_real,_imag);
}
Complex::Complex(_real,_imag)
{
real = _real;
imag = _imag;
}
var c = new(Complex,3,5);
// Allocates an instance of the class myClass.
class myClass
{
public:
myClass(); // Constructor
}
myClass::myClass()
{
// Do stuff
}
var object = new(myClass);