Skip to content

Commit

Permalink
Merge pull request #128 from leee1001/gh-pages
Browse files Browse the repository at this point in the history
2.18 章节 类型检查(Type Casting)遗漏代码补全
  • Loading branch information
vclwei committed Jun 12, 2014
2 parents 9957cb7 + 3c9d584 commit ba0cf26
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions source/chapter2/18_Type_Casting.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@

下一个代码段定义了 `MediaItem` 的两个子类。第一个子类`Movie`,在父类(或者说基类)的基础上增加了一个 `director`(导演) 属性,和相应的初始化器。第二个类在父类的基础上增加了一个 `artist`(艺术家) 属性,和相应的初始化器:

class Movie: MediaItem {
var director: String
init(name: String, director: String) {
self.director = director
super.init(name: name)
}
}

class Song: MediaItem {
var artist: String
init(name: String, artist: String) {
Expand Down

0 comments on commit ba0cf26

Please sign in to comment.