This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
s := NewSuper("Super!") | |
fmt.Println(s.Get()) | |
//基底クラスのgetから派生クラスのメソッドをオーバーライドして呼び出すことはできない | |
t := NewSub("Sub!") | |
fmt.Println(t.Get()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Base: | |
def __init__(self, str): | |
self.str = str | |
def make_string(self): | |
return "Hi, " + self.str | |
def get(self): | |
return self.make_string() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
s := Impl{NewSuper("Super!")} | |
fmt.Println(s.Get()) | |
//実装クラスのgetから派生クラスのメソッドを呼び出す | |
i := Impl{NewSub("Sub!")} | |
fmt.Println(i.Get()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
s := Super{} | |
fmt.Println(s.Get()) | |
//基底クラスのgetから派生クラスの関数をオーバーライドして呼び出すことはできない | |
t := Sub{} | |
fmt.Println(t.Get()) |
OlderNewer