struct student { var stuName = " " static var banji = "ios"}var xiaoming = student()xiaoming.stuName = "xiaoming"println(xiaoming.banji)小白还在看语法照着书试了一下println 静态属性为什么报错 student doesn't have a member named "banji"
3 回答
gix_ic
TA贡献6条经验 获得超0个赞
两个问题 首先 student 应该首字母大写 Student, 第二对于类或者结构体的静态属性应该直接用类名或者结构体的名称加点号调用 eg: Student.banji
RockenRoll
TA贡献35条经验 获得超13个赞
struct student {
var stuName = " "
static var banji = "ios"
}
这是个结构体啊,不是静态属性
- 3 回答
- 0 关注
- 1644 浏览
添加回答
举报
0/150
提交
取消