Previous Document Next Document

Understanding automation : What are the main elements of automation? : What is a class?


What is a class?

A class is the definition or description of an object. A class outlines the properties, methods, and events that apply to a type of object in an application; it acts as a template for all objects of that type class. To use a metaphor, the class “car” is a small vehicle with an engine and four wheels.

An object is an instance of a class. To extend the car metaphor, the actual, physical car purchased for the purposes of driving is an object (that is, an instance of the class “car”).

In the context of CorelDRAW, each open document is an instance of the Document class, each page in the document is an instance of the Page class, and each layer (and each shape on each layer) are more instances of more classes. For example, Document represents the Document class in the software program. However, ActiveDocument represents an object within that class because it makes specific reference to one object.

As previously discussed, objects are often made up of other smaller objects. For example, a car contains four objects of the class “wheel,” two objects of the class “headlight,” and so on. Each of these child objects has the same properties and methods of its class-type. This parent/child relationship of objects is an important one to recognize, particularly when referencing an individual object.

Some classes “inherit” features from their parents. For example, in the context of CorelDRAW, the Shape type has many subtypes (or “inherited types”), including Rectangle, Ellipse, Curve, and Text. All these subtypes can make use of the basic members of the Shape type, including methods for moving and transforming the shape and for setting its color. However, the subtypes also have their own specialist members; for example, a Rectangle can have corner radii, whereas Text has an associated Font property.

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.