Verse Library verse

11 Overloading

Defines an interface, implements it in classes, and demonstrates polymorphic function calls.

extracted-snippets/documentation/en-us/uefn/functions-in-verse/11-overloading.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/uefn/functions-in-verse
# Local doc:  epic-docs/documentation/en-us/uefn/functions-in-verse.md
# Section:    Overloading
as_int := interface:
    AsInt():int

ToInt(X:as_int):int = X.AsInt()

thing1 := class(as_int):
    AsInt():int = 1

thing2 := class(as_int):
    AsInt():int = 2

Main()<decides>:void =
    X := thing1{}
    ToInt(X) = 1
    Y := thing2{}
    ToInt(Y) = 2
Copy full snippet

Comments

    Sign in to vote, comment, or suggest an edit. Sign in