---
title: "class — Class definition"
description: "iXML command class: Class definition."
canonical_url: "https://www.zeyos.com/ixml/ref/class"
markdown_url: "https://www.zeyos.com/ai/guide/ixml/ref/class.md"
section: "ixml-reference"
authority: "reference"
language: "en"
source_repository: "https://cloud.zeyos.com/__doc/ixmldoc.xml"
source_sha256: "a23f04e6a98628ca3c273c3b8dd2c33c034cfda3e0f00478d8793074fd2f70dd"
---

# class — Class definition

The CLASS construct defines a class that can be instantiated with subsequent NEW statements. It serves as an array prototype for object-oriented design.

A class is used as a blueprint to create instances of itself. It defines constituent properties and methods which enable these class instances to have state and behavior. Upon instantiation the properties and methods of a class become the associated key and value pairs of a newly created array, which in the context of object-oriented design is to be termed an object.

Classes can be derived from multiple existing classes, thereby establishing a hierarchial relationship in which a parent class can be considered as a common part of its subclasses. Extending a class will have the subclass inherit all the properties and methods from the parent class.

The EXTENDS construct incorporates the properties, constructors and methods of a parent class, thereby overloading existing constituents.

The PROPERTY construct defines a property of the class, which upon instantiation will become a regular array item with its name as the key.

The CONSTRUCTOR construct defines a special type of subroutine as a code sequence that cannot be invoked directly but will automatically be called on each newly created object in order to establish the invariant of the class and put the object in some desired state upon instantiation. Upon instantiation parent constructors are automatically called along the lines of inheritance.

The METHOD construct defines a closed subroutine as a code sequence analog to the FUNCTION construct but with explicit reference to the corresponding class. Upon instantiation a class method becomes a regular array item with its name as the key and the underlying function as the value.

### Attributes
| Name | Type | Default | Description |
| ---- | ---- | ------- | ----------- |
| var | var |  | Variable name |

### Children
- extends (occurrence: multiple) — Extends
- property (occurrence: multiple) — Property
- constructor (occurrence: single) — Constructor
- method (occurrence: multiple) — Method

### Parents
- (not restricted in the reference)

### Result
- binding: var; type: class; predicate: no-result-propagation

### Examples

```xml
<class var="Human">
	<property name="gender">male</property>
</class>

<class var="Person">
	<extends class="Human"/>

	<property name="firstname"/>
	<property name="lastname"/>

	<constructor>
		<set var="this.firstname">$firstname</set>
		<set var="this.lastname">$lastname</set>
	</constructor>

	<method name="getName">
		<set var="return">$this.firstname $this.lastname</set>
	</method>
</class>

<new class="Person" var="obj">
	<param name="firstname">Bill</param>
	<param name="lastname">Gates</param>
</new>

<call func="obj.getName" var="name"/>
<output>$name is $obj.gender!</output>

<!-- Bill Gates is male! -->
```
