Tutorial part II Flashcards
What is the difference between an Object and a Tuple
They provide inheritance and information hiding.
Because objects encapsulate data, the T() object constructor should only be used internally and the programmer should provide a proc to initialize the object (this is called a constructor).
How to checko a type of an object
with ‘of’ operator
How to set a field of an object public
with the ‘*’ after the field name
How to define an object
type
Person = ref object of RootObj
name*: string # the * means that name
is accessible from other modulHes
age: int
How to define an inheritance
whit the object of operator
What is the convention to create an object without inheritance
using the RootObj