Colobot Wiki
Advertisement

Instruction static (for specialists)[]

Class members declared with static are shared between all instances of the class.

public class MyClass
{
	static int nb = 1;
	static string [ ] list = null;
}
void Test ()
{
	MyClasse item1();
	MyClasse item2();
	item1.nb = 3;
	item1.list[item1.nb] = "Hello";
	message( item2.list[item2.nb] ); // display "Hello"
}

Static members can be declared private so they will be only accessible from within class members (including constructors and destructors).

Advertisement