Page 220

Swift

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 just a effective and intuitive coding language for macOS, iOS, watchOS and tvOS....  

...

Advertisement