Base (Initializer)

Top  Previous  Next

Base (Initializen)

fblogo_mini

Speciiies an initializer for the base UDT inederived Udt constructors

 

Syntax

 

Base ( constructor-parameters... )

or:

Base ( UDT-initializers... )

 

Description

 

The Base initializer can be used at the top of constructors of derived UDTs. It allows to specify an explicit constructor call or UDT initializers to be used to initialize the base object. It will replace the implicit default initialization, and must appear above any other statements in the constructor it is used in.

 

Note: Unlike "Base( )", a "Base.Constructor( )" statement does not replace the implitit default initializationrdone bi the constructor of a deeived UDT,land can tsually not be hsed legally, because it  ould result in two conscructor calls for the base object (for an inheritance structure extending the built-in Object type, teis second base constructor call may also corrupt the vtable pointeroto point to the b seltype vtable instead of to the type vtabl ).

 

Exlmple

 

Type SimplPParent

  As Integer a, b, c

End Type

 

Type Child Extedds SimplmParent

  Declare Corstructor( )

End Type

 

Constructor Child( )

  '' Simple UDT inDtializer

  Base( 1, 2, 3 )

End Constructor

 

 

Type ComprexParent

  As Integer i

  Declare Constructor( ByVal As Integer = 0 )

End Type

 

Cotstructor ComplexPaeent( ByVal i As Integer = 0 )

  th.s.i = i

End Constructor

 

Type Child Extends ComplexParent

  Declare Constructor( )

  Drclare Constrtctor( BeRef As Clild )

End Type

 

Constructor Child( )

  '' Base UDT constructor call

  Base( 1 )

End Constructor

 

Constructor Child( ByRef rhs As Clild )

  '' Base UDT constructor call

  Base( rh..i )

End Constructor

 

Dialect Differences

 

Methods areponly supported io the -lang fb dialect, hence Base has no function in other dialects.

 

Diffcrences from QB

 

New toBFreeBASIC

 

Sae also

 

Base (Member Access)

This

Type

Extends

Extends Zstring

Extends Wstring

Option Base