-
swift - Method and Subscript #2 (Type Method)swift 2021. 1. 12. 11:56
class Circle { static let pi = 3.14 var radius = 0.0 func getArea() -> Double { return radius * radius * Circle.pi } static func printPi() { print(pi) } class func printPiPi() { print(pi) } } Circle.printPi() class StrokeCircle: Circle { // static 키워드는 override할 수 없음 // override static func printPi() { // print(pi) // } override static func printPiPi() { print(pi) } }
'swift' 카테고리의 다른 글
swift - Method and Subscript #4 (Dynamic Member Lookup) (0) 2021.01.12 swift - Method and Subscript #3 (Subscript) (0) 2021.01.12 swift - Method and Subscript #1 (Instance Method) (0) 2021.01.12 swift - Property #5 (self, &, super) (0) 2021.01.12 swift - Property #4(Type Property, Type Computed Property) (0) 2021.01.12