GOLANG学习24. 定义链表
package main
import (
"fmt"
)
/**
*定义链表
*/
type Student struct {
Name string
Age int
Score float32
Next *Student
}
func main() {
var head Student
head.Name = "张三"
head.Age = 20
head.Score = 99.9
var stu1 Student
stu1.Name = "李四"
stu1.Age = 30
stu1.Score = 88.8
head.Next = &stu1
//定义一个指针变量从头开始头
var p *Student = &head
for p != nil {
fmt.Println(*p)
p = p.Next
}
}