#エラー内容
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-5-b4a7c5c0a34c> in <module>() 23 24 ---> 25 class Class_3(ClassDesignDrawing, Class_2_Inheritance): 26 pass 27 TypeError: Cannot create a consistent method resolution order (MRO) for bases ClassDesignDrawing, Class_2_Inheritance
class Class_2_Inheritance(ClassDesignDrawing):# クラスは継承(Inheritance)が可能 継承先のこのクラスをサブクラスという
def init(self,name): # コンストラクタという
self.name = name # self.nameはインスタンス変数。「インスタンス.変数名」で表示可能
def world(self): print ("World") def hello(self): # サブクラスは親クラスのhello()メソッドをオーバーライドする事ができる print("HELLO HELLO これサブクラス書換え!")# class ClassDesignDrawingの hello(self)をオーバーライドしている
class Class_3(ClassDesignDrawing, Class_2_Inheritance):
pass
a = MyClassC()
a.hello() # ClassDesignDrawing のメソッドも
a.world() # Class_2_Inheritance のメソッドも使用できる
回答の取得に失敗しました