Go結構可以從另一個結構的類型繼承一組值嗎?這樣的事情。type Foo struct { Val1, Val2, Val3 int}var f *Foo = &Foo{123, 234, 354}type Bar struct { // somehow add the f here so that it will be used in "Bar" inheritance OtherVal string}這會讓我做到這一點。b := Bar{"test"}fmt.Println(b.Val2) // 234如果沒有,可以使用什么技術來實現類似的效果?
- 1 回答
- 0 關注
- 156 瀏覽
添加回答
舉報
0/150
提交
取消