Colobot Wiki
Advertisement

This is an access modifier for class members. Protected class members can be accessed in a child class, but they can't be accessed outside of classes definitions being part of the same inheritance tree (see the extends keyword).

Example[]

public class Parent
{
	protected int field = 0;
}


public class Child extends Parent
{
	void Print()
	{
		message(field);
	}
}
extern void object::Test()
{
	Child child();
	child.Print(); // 0
	//child.field = 1; // Error!
}

See also[]

Class, public, private, extends

CBOT Language, types, and categories.

Advertisement