皆様いつもお世話になっております。
クラスの継承を勉強中なのですが
python
1class Prism: 2 def __init__(self, width, height, depth, unit='cm'): 3 self.width = width 4 self.height = height 5 self.depth = depth 6 self.unit = unit 7 8 def content(self): 9 return self.width * self.height * self.depth 10 11 def unit_content(self): 12 return str(self.content()) + self.unit 13 14 15p = Prism(20, 20, 20) 16print(str(p.content()) + ' is Prism') 17print(p.unit_content()) 18 19 20class Cube(Prism): 21 def __init__(self, length): 22 super().__init__(length, length, length) #<--これが何をしているのか理解できません 23 self.width = self.height = self.depth = length 24 25 26c = Cube(10) 27print(str(c.content()) + ' is Cube') 28print(c.unit_content()) 29
Prismクラスの
python
1__init__(self, width, height, depth, unit='cm')
をCubeクラスの中に呼び出しているだけでしょうか?
ご教授のほどよろしくお願いします。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/07/23 13:24
2017/07/23 13:33 編集
2017/07/23 14:35
2017/07/23 17:19
2017/07/23 21:44