mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 05:33:04 +08:00
@@ -228,7 +228,7 @@ type Node struct {
|
||||
type Node struct {
|
||||
pr *Node
|
||||
data float64
|
||||
su *su
|
||||
su *Node
|
||||
}
|
||||
```
|
||||
|
||||
@@ -285,7 +285,7 @@ func main() {
|
||||
提示:
|
||||
VCard 必须包含住址,它应该以值类型还是以指针类型放在 VCard 中呢?
|
||||
第二种会好点,因为它占用内存少。包含一个名字和两个指向地址的指针的 Address 结构体可以使用 %v 打印:
|
||||
{Kersschot 0x126d2b80 0x126d2be0}
|
||||
{Kersschot 0x126d2b80 0x126d2be0}
|
||||
|
||||
**练习 10.2** persionext1.go:
|
||||
|
||||
@@ -293,7 +293,7 @@ func main() {
|
||||
|
||||
**练习 10.3** point.go:
|
||||
|
||||
使用坐标 X、Y 定义一个二维 Point 结构体。同样地,对一个三维点使用它的极坐标定义一个 Polar 结构体。实现一个 `Abs()` 方法来计算一个 Point 表示的向量的长度,实现一个 `Scale` 方法,它将点的坐标乘以一个尺度因子(提示:使用 `math` 包里的 `Sqrt` 函数)(function Scale that multiplies the coordinates of a point with a scale
|
||||
使用坐标 X、Y 定义一个二维 Point 结构体。同样地,对一个三维点使用它的极坐标定义一个 Polar 结构体。实现一个 `Abs()` 方法来计算一个 Point 表示的向量的长度,实现一个 `Scale` 方法,它将点的坐标乘以一个尺度因子(提示:使用 `math` 包里的 `Sqrt` 函数)(function Scale that multiplies the coordinates of a point with a scale
|
||||
factor)。
|
||||
|
||||
**练习 10.3** rectangle.go:
|
||||
|
Reference in New Issue
Block a user