Copyright © 2024 SingChun Lee Bucknell University. All rights reserved. Sites developed using revealjs.
Class A:
Def foo() { print "I'm in a" }
Class B inherits A:
Def foo() { print "I'm in b" }
A test = new B() // test : A, contents are B's
test.foo() // which foo() runs?
Class A:
Def foo() { print "I'm in a" }
Class B inherits A:
Def foo() { print "I'm in b" }
A test = new B() // test : A, contents are B's
test.foo() // which foo() runs?
Class A:
Def foo() { print "I'm in a" }
Def bar() { call foo() }
Class B inherits A:
Def foo() { print "I'm in b" }
// Note: B inherits A's bar()
test = new B() // test has no type or inferred type (i.e. B)
// but the contents are B's
test.bar() // which foo() runs?
Class A:
Def foo() { print "I'm in a" }
Def bar() { call foo() }
Class B inherits A:
Def foo() { print "I'm in b" }
// Note: B inherits A's bar()
test = new B() // test has no type or inferred type (i.e. B)
// but the contents are B's
test.bar() // which foo() runs?