Export (0) Print
Expand All

hide Modifier

Declares that a method or property hides a method or property in a base class.

hide statement

statement

Required. A method or property definition.

The hide modifier is used for a method that hides a method in a base class. You are not allowed to use the hide modifier for a method unless the base class has a member with the same signature.

Methods and properties in classes can be marked with the hide modifier. Classes, fields, interfaces and members of interfaces cannot take the hide modifier.

You may not combine the hide modifier with the other version-safe modifier (override). The version-safe modifiers cannot be combined with the static modifier. By default, a method will override a base-class method unless the base-class method has the final modifier. You cannot hide an abstract method unless you provide an explicit implementation for the abstract, base method. When running in version-safe mode, one of the version-safe modifiers must be used whenever a base-class method is overridden.

The following example illustrates a use of the hide modifier. The method in the derived class marked with the hide modifier does not override the base-class method. The method marked with override does override the base-class method.

class CBase {
   function methodA() { print("methodA of CBase.") };
   function methodB() { print("methodB of CBase.") };
}

class CDerived extends CBase {
   hide function methodA() { print("Hiding methodA.") };
   override function methodB() { print("Overriding methodB.") };
}


var derivedInstance : CDerived = new CDerived;
derivedInstance.methodA();
derivedInstance.methodB();

var baseInstance : CBase = derivedInstance;
baseInstance.methodA();
baseInstance.methodB();

The output of this program shows that a hidden method does not override a base class method.

Hiding methodA.
Overriding methodB.
methodA of CBase.
Overriding methodB.

Community Additions

ADD
Show:
© 2014 Microsoft