importFoundation
//接口的定义关键字protocol
protocolPeople{
funcgetname()->NSString
funcgetage()->Int
}
//实现相应该接口
classman :People{
varname:NSString!=""
varage:Int!=0
init(){
name="";age=0;
}
funcsetname(myname:NSString){
name= myname
}
funcsetage(myage:Int){
age= myage
}
NSString{
returnname
}
Int{
age
}
}
varmyman =man();
myman.setname("myman test")
println(getname())
importFoundation
//接口的定义关键字protocol
protocolPeople{
NSString
Int
}
//实现相应该接口
People{
""
0
init(){
0;
}
NSString){
name= myname
}
Int){
age= myage
}
NSString{
name
}
Int{
age
}
}
man();
)
())