25
edits
Changes
→Classes:
==== Classes: ====
A class is a type of collection that can contain collects ''variables'' and ''constants'', ''called fields'', as well as ''functionsprocedures'' and ''iterators'' called methods. A new class type is declared using the We use '''class''' keywordto declare a new class type.
class C myClass {
var a, b: int;
proc printFieldsprint() {
writeln("a = ", a, " b = ", b);
}
The '''new''' keyword creates an instance of a class by calling an initializer.
var foo = new CmyClass(0, 1, 3); foo.printFieldsprint();
==== Records: ====