go语言指针访问结构体的方法
2016-02-25 23:54
651 查看
Go有指针,但是没有指针运算。
结构体字段可以通过结构体指针来访问。通过指针间接的访问是透明的。
复制代码代码如下:
package main
import "fmt"
type Vertex struct {
X int
Y int
}
func main() {
p := Vertex{1, 2}
q := &p
q.X = 1e9
fmt.Println(p)
}
结构体字段可以通过结构体指针来访问。通过指针间接的访问是透明的。
复制代码代码如下:
package main
import "fmt"
type Vertex struct {
X int
Y int
}
func main() {
p := Vertex{1, 2}
q := &p
q.X = 1e9
fmt.Println(p)
}
相关文章推荐
- UVA 225(p214)----Golygons
- NSDate和NSDateFormatter的使⽤、Category、Extension、Protocol、delegate
- Learn Some Framework-3 From Zygote to HOME
- LightOJ 1259 Goldbach`s Conjecture(数论)
- Google Guava官方教程(中文版 转载)
- NS2中GOD的使用
- Django学习随手记(四)
- Django~automated tests
- 仅当使用了列的列表,并且IDENTITY_INSERT为ON时,才能在表'goldlog'中为标识列指定显式值
- Pymongo: TypeError: if no direction is specified, key_or_list must be an instance of list
- Django~Models1
- mongoose使用的抓狂
- golang笔记——流程控制
- GoogLeNet系列解读
- Google Guava 类库 笔记
- Django ~module index
- 【SPOJ-COINS】Bytelandian gold coins【DP】
- django的404,500错误自定义页面的配置
- [mongo] mongoose增删改查操作
- The backtracking algorithm