-
Notifications
You must be signed in to change notification settings - Fork 0
Language Concepts: Classes
Luiz Fernando edited this page Feb 27, 2015
·
2 revisions
In ZScript, it is possible to program in an OOP manner by using class constructs.
Classes behave much like in other OOP programming languages: they couple fields with functions in a single object.
Bellow is an example of a class implemented in ZScript
class FriendlyClass
{
var name:string;
func FriendlyClass(n:string)
{
name = n;
}
func sayHello()
{
print("Hello, " + name + "!");
}
}
...
var friendly = FriendlyClass("John Doe"); // Note there's no 'new' before calling the constructor
friendly.sayHello();Classes are defined with the following syntax:
class <classname> [: <baseClass>]
{
// Class contents...
}