class Huamn {
var name = ""
var age = 0
func show() -> Void {
print("\(name)")
}
func run() -> Void {
print("run")
}
}
var h = Huamn()
h.name = "旺旺"
h.age = 20
h.show()
h.run()
class DataBase {
static var defaultDB:DataBase? = nil
var name = ""
private init() {
}
static func shared() -> DataBase {
if defaultDB == nil {
defaultDB = DataBase()
}
return defaultDB!
}
}
//
//var db1 = DataBase()
//db1.name = "dbOne"
//
//var db2 = DataBase()
//db2.name = "db2!"
var db3 = DataBase.shared()
db3.name = "数据库3"
var db4 = DataBase.shared()
db4.name = "数据库4"
//print(db1.name,db2.name)
print(db3.name,db4.name)
var num = 5 & 3
print(num)
num = 5 | 3
print(num)
num = 5 ^ 3
print(num)
num = 5 << 2
print(num)
num = -5 & 3
print(num)
num = -5 ^ -3
print(num)
num = -5 << 2
print(num)
swift访问控制
最新推荐文章于 2024-02-19 17:54:43 发布