Revision [16267]

This is an old revision of KeyPgExtends made by FxMwikki on 2012-08-12 13:08:13.

 

EXTENDS


Specifies a base type from which to derive a new type

Syntax:
KeyPgType Type typename Extends base_typename
...
End KeyPgType Type

Description:
Extends declares typename to be derived from base_typename. The derived user-defined type, typename, inherits fields and methods of the base_typename base type. typename objects may be used in place of base_typename objects. Fields and methods inherited from base_typename will be implicitly accessible like regular members of typename. However, regular members will override inherited members if they have the same identifier. The KeyPgBase Base (member access) keyword can be used to explicitly access members of the base type.

User-defined types that extend another type will include the base type structure at their beginning, and their size as reported by KeyPgSizeOf sizeof() is the sum of their base type's size plus the size needed for any regular members. Since the inherited members make sure that the structure is not empty, a derived type is not required to have regular members of its own.

The KeyPgBaseInit Base (initializer) keyword can be used at the top of constructor of derived user-defined type. It allows to specify an initializer or constructor call for the base type.

Extending the built-in KeyPgObject Object type allows a user-defined type to be used with KeyPgOpIs Operator Is to perform run-time type checks.

Remark: Derived UDT pointer can only be casted to "compatible" pointer types (up/down the inheritance hierarchy) or Any Ptr. Otherwise, cast to Any Ptr first.

Warning: Before fbc version 0.24, these five keywords dedicated to inheritance Extends, KeyPgBase Base (member access), KeyPgBaseInit Base (initializer), KeyPgObject Object and KeyPgOpIs Operator Is are not supported.

Examples:

Dialect Differences:
Differences from QB:
See also:
Back to User Defined Types
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode