I'm learning to do class inheritance, and there's something I don't understand. First, I show you the code.
class Persona {
var edad : Int
var nombre : String
var telefono : Int
init(edad: Int, nombre: String, telefono: Int) {
self.edad = 0
self.nombre = nombre
self.telefono = 123456789
}
}
class Cliente: Persona {
var credito : Int
init(credito: Int) {
self.credito = 0
super.init(edad: <Int>, nombre: <String>, telefono: <Int>)
}
}
Well, when I write el in the subclass super.init
, Xcode warns me that I have to give it the parameters, which I would like to give them when creating an object of the subclass. If I try to create:
var unCliente = Cliente(credito: Int)
it only lets me give it the credit parameter and not the parameters of the parent class Person.
So my question is this: should I give it the parameters when creating the subclass? Is it possible to do what I try?