This commit is contained in:
Mark McGranaghan 2012-09-16 14:29:12 -07:00
parent 8a6928e2ce
commit dd455da020
2 changed files with 31 additions and 0 deletions

15
30-new.go Normal file

@ -0,0 +1,15 @@
package main
import "fmt"
func one(xPtr *int) {
*xPtr = 1
}
func main() {
xPtr := new(int)
fmt.Println(xPtr)
fmt.Println(*xPtr)
one(xPtr)
fmt.Println(xPtr)
fmt.Println(*xPtr)
}

16
31-structs.go Normal file

@ -0,0 +1,16 @@
package main
import "fmt"
type Circle struct {
x, y, r float64
}
func main() {
cEmptyPtr := new(Circle)
fmt.Println(cEmptyPtr)
fmt.Println(*cEmptyPtr)
cValue := Circle{x: 1, y: 2, r: 5}
fmt.Println(&cValue)
fmt.Println(cValue)
}