Add support for multiple interfaces
This commit is contained in:
@@ -5,28 +5,34 @@ interface Printable
|
||||
func print()
|
||||
}
|
||||
|
||||
struct Human : Printable
|
||||
interface Stringable
|
||||
{
|
||||
func str(): cstring
|
||||
}
|
||||
|
||||
struct Human : Printable, Stringable
|
||||
{
|
||||
name: cstring
|
||||
|
||||
func str(): cstring
|
||||
{
|
||||
return this^.name
|
||||
}
|
||||
|
||||
func print()
|
||||
{
|
||||
puts(this^.name)
|
||||
puts(this^.str())
|
||||
}
|
||||
}
|
||||
|
||||
func main(args: []cstring): i64
|
||||
{
|
||||
let human = alloc Human {
|
||||
let human: Stringable = alloc Human {
|
||||
name = "oliver"
|
||||
}
|
||||
|
||||
human.print()
|
||||
print_printable(human)
|
||||
puts(human.str())
|
||||
// human.print()
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func print_printable(printable: Printable)
|
||||
{
|
||||
printable.print()
|
||||
}
|
||||
Reference in New Issue
Block a user