more
This commit is contained in:
parent
f497e342f2
commit
03c8a4983a
22
34-embedding.go
Normal file
22
34-embedding.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
type Person struct {
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Person) Talk() {
|
||||||
|
fmt.Println("Hi, my name is", p.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Android struct {
|
||||||
|
Person
|
||||||
|
Model string
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
android := new(Android)
|
||||||
|
android.Name = "Milo"
|
||||||
|
android.Talk()
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user