main Student { name string age int sex string } (s *Student) SetName(name string) { s.name == name { fmt.Println() } { s.name = name fmt.Println() } } (s *Student) GetName() string { s.name } main(){ S1 := &Student{,,} A:=S1.SetName A() B := (*Student).SetName B(S1,) fmt.Println(S1.GetName()) }
来源:https://www.cnblogs.com/aiaitie/p/11806190.html