This commit is contained in:
2024-08-01 23:40:06 +08:00
commit 1adca2ffe6
17 changed files with 469 additions and 0 deletions

35
main/pt.go Normal file
View File

@@ -0,0 +1,35 @@
package main
import (
"fmt"
)
func main() {
//创建对象实例
var T teacher = teacher{}
T.Name = "dakjda"
fmt.Println(T)
//使用指针创建对象
var t *teacher = new(teacher)
(*t).school = "没用"
(*t).age = 19
fmt.Println(t)
var s student
var p person
s = student(p)
fmt.Println(s)
}
// 定义结构体 方便内存管理
type teacher struct {
Name string
age int64
school string
}
type student struct {
age int
}
type person struct {
age int
}