Share via


Subclasses in Visual FoxPro

You can create a new class or a subclass from most of the Visual FoxPro base classes or other existing classes. A subclass can include some or all the functionality of the original, or parent, class, plus any additional characteristics, such as custom default properties, or functionality that you want to include to customize the new class.

Creating and using subclasses offer the benefits of reusability by helping to decrease the amount of code you need to write, and inheritance, which saves time and effort updating classes when you make changes to a parent class. When you modify a parent class, the changes you make propagate to all subclasses that inherit from the parent class.

For example, suppose you have a command button class. You can create a subclass from the command button class that contains all the standard properties, methods, and events for a command button plus additional properties or functionality you want to include, such as displaying the command button with a certain color or size or performing actions such as displaying a specific message when clicked.

Subclasses are not limited to a single class. For example, you can add multiple controls to a container class definition, such as a form class. Many of the classes in the Visual FoxPro sample class library fall into this category. For more information, see Sample Class Libraries.

See Also

Tasks

How to: Create Classes and Subclasses

Concepts

Considerations for Creating Classes

Working with Classes in Visual FoxPro