Build Subclasses with Superclasses

This section describes how to build subclasses with superclasses.

The $append statements inside the class definition body can be used to build subclasses with superclasses. No additional new statements needed.

In the example below, "person" is considered as a superclass; and "employee" is considered as a subclass.

$class person: {
   $instance x: {;
	  $method x._first(name="John") { = name;
	  $method x.changeName(name): { = name; 

$class employee: {
   $instance x: {
	  $method x._first(name="Maria", status="Part-time") {
	     $append x $with person(name);
		 x.status = status;
	  $method x.changeStatus(status): {
	     x.status = status;
	  $method x.print(): {

e = employee(name="Herong", status="Full-time");

Table of Contents

 About This Book

 Introduction of H Language


 Data Types




 "boolean" Data Type

 "integer" Data Type

 "string" Data Type

 "real" Data Type

 "array" Data Type

 Source Code Packages

 Classes and Objects

 Object Oriented Programming

Inheritance - Object Attachments

 What Is Object Attachment

 $append Statement - Attach Objects

 Name Collision in Attached Objects

 Append Multiple Object Attachments

 $trim Statement - Detach Objects

Build Subclasses with Superclasses

 Object Morphinism by Changing Attachments

 Encapsulation - Private Members


 Full Version in PDF/ePUB