提交 b5e6792f 编写于 作者: W Wenlei

add an illustration

give a diagram for demonstrating the relationship among student human
and skills
上级 800d2fe2
...@@ -122,6 +122,9 @@ Go语言中,也和C或者其他语言一样,我们可以声明新的类型 ...@@ -122,6 +122,9 @@ Go语言中,也和C或者其他语言一样,我们可以声明新的类型
fmt.Println("His weight is", mark.weight) fmt.Println("His weight is", mark.weight)
} }
图例如下:
![](images/2.4.student_struct.png?raw=true)
我们看到Student访问属性age和name的时候,就像访问自己所有用的字段一样,对,匿名字段就是这样,能够实现字段的继承。是不是很酷啊?还有比这个更酷的呢,那就是student还能访问Human这个字段作为字段名。请看下面的代码,是不是更酷了。 我们看到Student访问属性age和name的时候,就像访问自己所有用的字段一样,对,匿名字段就是这样,能够实现字段的继承。是不是很酷啊?还有比这个更酷的呢,那就是student还能访问Human这个字段作为字段名。请看下面的代码,是不是更酷了。
mark.Human = Human{"Marcus", 55, 220} mark.Human = Human{"Marcus", 55, 220}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册