H (Hybrid) Language - v0.03, by Dr. Herong Yang
$public Modifier on Instance Members
This section describes the $public modifier on Instance members (variables and functions).
By default, all instance members (properties and methods) are public. They can be accessed from outside the instance definition body.
But if you want to make the code more readable, you use the $public modifier to declare instance members to be publicly accessible.
Examples of using $public modifier on instance members:
$class account: { $insance x: { $public x.balance = 0.0; $public $method x.deposit(amount): { x.balance = x.balance + amount; }; $public $method x.withdraw(amount): { x.balance = x.balance - amount; }; $public $method x.printBalance(): { write(x.balance); }; } } checking = account(); checking.deposit(100.0); checking.deposit(80.0); checking.printBalance(); # prints 20.0
Table of Contents
Inheritance - Object Attachments
►Encapsulation - Private Members
$public Modifier on Class Members
$private Modifier on Class Members
►$public Modifier on Instance Members
$private Modifier on Instance Members