Repository navigation
Base Initializer
Home › User Defined Types › Base (Initializer)
Specifies an initializer for the base UDT in derived Udt constructors
Base ( constructor-parameters... )
or:
Base ( UDT-initializers... )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 (Member Access).Constructor( )" statement does not replace the implicit default initialization done by the constructor of a derived UDT, and can usually not be used legally, because it would result in two constructor calls for the base object (for an inheritance structure extending the built-in Object type, this second base constructor call may also corrupt the vtable pointer to point to the base-type vtable instead of to the type vtable).
- Methods are only supported in the -lang fb dialect, hence
Basehas no function in other dialects.
- New to FreeBASIC
Type SimpleParent
As Integer a, b, c
End Type
Type Child Extends SimpleParent
Declare Constructor( )
End Type
Constructor Child( )
'' Simple UDT initializer
Base( 1, 2, 3 )
End ConstructorType ComplexParent
As Integer i
Declare Constructor( ByVal As Integer = 0 )
End Type
Constructor ComplexParent( ByVal i As Integer = 0 )
this.i = i
End Constructor
Type Child Extends ComplexParent
Declare Constructor( )
Declare Constructor( ByRef As Child )
End Type
Constructor Child( )
'' Base UDT constructor call
Base( 1 )
End Constructor
Constructor Child( ByRef rhs As Child )
'' Base UDT constructor call
Base( rhs.i )
End ConstructorCategory: User Defined Types
Kind: keyword
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing