class Student
{
final var name:String = ""
private var age:Int = 0
private var score:Double = 0.0
private var ispass:Bool = false
public static let schoolName = "第五代"
convenience init()
{
self.init(name:"浏览量",age:33,score:59)
}
init(name:String, age:Int, score:Double) {
self.name = name
self.age = age
self.score = score
ispss(param: score)
}
private func ispss(param:Double)
{
self.score = param
if self.score < 60 {
self.ispass = false
}else{
self.ispass = true
}
}
}
var s1 = Student()
print(s1.name)
class Student
{
var name = "hello"
}
var s1 = Student()
print(s1.name)
var s2 = s1
s2.name = "1111"
print(s2.name)
print(s1.name)
class Person
{
private var name:String
private var age:Int
init(name:String,age:Int) {
self.name = name
self.age = age
}
public func setName(name:String)
{
self.name = name
}
public func setAge(age:Int)
{
self.age = age
}
public func getName() -> String
{
return self.name
}
public func getAge() -> Int
{
return self.age
}
}
class Student: Person
{
}
var per = Person(name: "张三", age: 20)
print(per.getName())
print(per.getAge())
var stu = Student(name: "学生", age: 14)
print(stu.getName())
swift5.0 类
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 先看效果避免耽搁大家时间 没有代码示范的代码不是好代码,附上demo 代码使用: funcimagePickerC...
- 我们之前发过关于推送的文章iOS 推送通知及通知扩展,其中介绍了推送相关流程及代码实现,不过使用OC实现的,现在我...