more
This commit is contained in:
parent
8a6928e2ce
commit
dd455da020
15
30-new.go
Normal file
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
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)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user