can anyone please help with the below code. I am trying to understand multiple inheritance not sure why its not working. BTW below if the code for multiple inheritance. Thanks
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Test Doc</title>
<script type="text/javascript">
function classX(){
this.messageX="this is X Message";
this.alertX=function(){
alert(this.messageX);
};
}
function classY(){
this.messageY="this is Y Message";
this.alertY=function(){
alert(this.messageY);
};
}
function classZ(){
classX.apply(this);
classY.apply(this);
this.messageZ="this is Z Message";
this.alertZ=function(){
alert(this.messageZ);
};
}
var abjz=new classZ();
objz.alertZ();
abjz.alertX();
</script>
</head>
<body>
</body>
</html>
You misspelled “abjz” in the call to “alertZ()”.
With that corrected, the code works fine, as far as I can tell (two alerts show up, one for Z and one for X).