"Fossies" - the Fresh Open Source Software Archive

Member "FreeBASIC-1.09.0-win64/examples/manual/udt/abstract1.bas" (1 Jan 2022, 914 Bytes) of package /windows/misc/FreeBASIC-1.09.0-win64.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Visual Basic source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 '' examples/manual/udt/abstract1.bas
    2 ''
    3 '' NOTICE: This file is part of the FreeBASIC Compiler package and can't
    4 ''         be included in other distributions without authorization.
    5 ''
    6 '' See Also: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgAbstract
    7 '' --------
    8 
    9 Type Hello Extends Object
   10     Declare Abstract Sub hi( )
   11 End Type
   12 
   13 Type HelloEnglish Extends Hello
   14     Declare Sub hi( )
   15 End Type
   16 
   17 Type HelloFrench Extends Hello
   18     Declare Sub hi( )
   19 End Type
   20 
   21 Type HelloGerman Extends Hello
   22     Declare Sub hi( )
   23 End Type
   24 
   25 
   26 Sub HelloEnglish.hi( )
   27     Print "hello!"
   28 End Sub
   29 
   30 Sub HelloFrench.hi( )
   31     Print "Salut!"
   32 End Sub
   33 
   34 Sub HelloGerman.hi( )
   35     Print "Hallo!"
   36 End Sub
   37 
   38 
   39     Randomize( Timer( ) )
   40 
   41     Dim As Hello Ptr h
   42 
   43     For i As Integer = 0 To 9
   44         Select Case( Int( Rnd( ) * 3 ) + 1 )
   45         Case 1
   46             h = New HelloFrench
   47         Case 2
   48             h = New HelloGerman
   49         Case Else
   50             h = New HelloEnglish
   51         End Select
   52 
   53         h->hi( )
   54         Delete h
   55     Next