Navigation  without Java Scripts

Objects - Class Instances

When a class declaration and implementation have been made, a multiple number of instances (objects) of this class can be created.

A new object of a class is created with a call to a constructor new for this class. Predicate new returns an object identifier that can be used to call the predicates and facts of this object.

Each instance of a class will have its own copies of the non-static facts.

Once created objects will survive fail; that is, fail does not delete created objects and does not deallocate the memory occupied by objects. To delete an object and to free the occupied resources you have to call the destructor delete explicitly.

Saving the object identifier you will be able to access and to use members of the object after fail. This is demonstrated in the following modification of the previous example.

See also