How Inheritance Affects PROTECTED Methods and Properties

ID: Q128633

3.00 WINDOWS kbprg

The information in this article applies to:

  • Microsoft Visual FoxPro for Windows, version 3.0

SUMMARY

This article explains how protected properties and methods are inherited when a class is derived from another class definition. It specifically addresses these issues:

  • Whether a protected class member is inherited and thus visible to a derived class.
  • Whether it is possible to modify the protected status of a member variable.

MORE INFORMATION

Members variables (properties) or procedures (methods) are by default visible outside a class definition. Once an object has been instantiated, its properties and methods can be accessed by other objects. The PROTECTED keyword prevents access to the Object's properties and methods from outside the object's definition.

A PROTECTED property or method is visible to the member functions of the class that declared these members, and it is visible to the member functions of a class derived from this class. In other words, protected properties, objects members, and methods are inherited.

When PROTECTED members are inherited, they still have a PROTECTED status. Although it is possible to redefine the content of properties and methods in a derived class, the PROTECTED status of a member variable cannot be overridden. If you need to modify this status in a subclass, you can add a member variable to the class. The goal of the new property or method that is visible to other objects is to access the PROTECTED member variable from within the class definition.

Additional reference words: VFoxWin 3.00 KBCategory: kbprg KBSubcategory: FxprgClassoop

Keywords          : FxprgClassoop 
Version           : 3.00
Platform          : WINDOWS


Last Reviewed: May 1, 1996
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.