Page 220


Protocol Inheritance Swift allows protocols to inherit properties from its defined properties. It is similar to that of class inheritance, but with the choice of listing multiple inherited protocols separated by commas. protocol classa { var no1: Int { get set } func calc(sum: Int) }

protocol result { func print(target: classa) }

class student2: result { func print(target: classa) { target.calc(1) } }

class classb: result { func print(target: classa) { target.calc(5) } }

class student: classa { var no1: Int = 10

func calc(sum: Int) { no1 -= sum println("Student attempted \(sum) times to pass")

if no1 <= 0 { println("Student is absent for exam") } } 208

​Quick is a effective and user-friendly coding language for macOS, iOS, watchOS and tvOS....  


Read more
Read more
Similar to
Popular now
Just for you