例)Python
例)Java
class Employee(Person):
def __init__(self):
super.__init__(self) # 親クラスの初期化メソッドを呼び出し。
public class Employee extends Person {
public Employee() {
super(); // 親クラスのコンストラクタ呼び出し。
}
}
JavaプログラマのためのPython入門。その違いについてソースコードをメインに比較していきます。 Pythonの対象バージョンはGoogleAppEngineと同様2.5としています。
例)Java
class Employee(Person):
def __init__(self):
super.__init__(self) # 親クラスの初期化メソッドを呼び出し。
public class Employee extends Person {
public Employee() {
super(); // 親クラスのコンストラクタ呼び出し。
}
}
例)Java
# 単継承
class SingleExtendsClass(Base1):
<文-1>
.
.
.
<文-N>
# 多重継承
class MultiExtendsClass(Base1, Base2, Base3):
<文-1>
.
.
.
<文-N>
/**
* 単継承しかできない。
*/
public class SingleExtendsClass extends Base1 {
<文-1>
.
.
.
<文-N>
}