source code c++ multiply inheritance
#include{
class KendBermotor {
public $mesin;
private $roda;
protected $jalur;
function __construct() {
$this->mesin = "Kendaraan Bermotor Punya Mesin
";
$this->roda = "Kendaraan Bermotor Punya Roda
";
$this->jalur = "Kendaraan Bermotor Punya Jalur
";
}
function getMesin() {
return $this->mesin;
}
function getJalur() {
return $this->jalur;
}
function getRoda() {
return $this->roda;
}
}
class KapalLaut extends KendBermotor {
private $baling2;
function __construct() {
$this->mesin = "Kapal Laut Punya Mesin
";
$this->jalur = "Kapal Laut Punya Jalur
";
$this->baling2 = "Kapal Laut Punya Baling-baling
";
$this->roda = "Kapal Laut Punya Roda";
}
function getBaling2() {
return $this->baling2;
}
}
$KB = new KendBermotor();
echo "
Kriteria Kendaraan Bermotor :
";
echo $KB->getMesin();
echo $KB->getRoda();
echo $KB->getJalur();
$KL = new KapalLaut();
echo "
Kriteria Kapal Laut :
";
// Dapat diakses
echo $KL->getMesin();
echo $KL->getBaling2();
echo $KL->getJalur();
?>
}