package main import "fmt" type Cat struct{ Name string Age int Color string Hobby string } func main(){ var cat1 Cat cat1.Name = "小白" cat1.Age = 3 cat1.Color = "白色" cat1.Hobby = "吃鱼" fmt.Println("cat1=", cat1) fmt.Println("猫猫的信息如下:") fmt.Println("name=", cat1.Name) fmt.Println("Age=", cat1.Age) fmt.Println("color=", cat1.Color) fmt.Println("hobby=", cat1.Hobby) }
本文来自博客园,作者:孙龙-程序员,转载请注明原文链接:https://www.cnblogs.com/sunlong88/p/11165973.html