ljr/wcmtools/s2/tests/super.s2

38 lines
523 B
C++
Executable File

#-*-c++-*-
layerinfo "type" = "core";
layerinfo "majorversion" = 0;
class Dog
{
var string name;
function out;
}
class KillerDog extends Dog
{
var int weight;
}
function Dog::out {
println "I'm a dog named \"$.name\".";
}
function KillerDog::out {
println "I'm a killer dog named \"$.name\" with weight $.weight";
$super->out();
}
function main ()
{
var KillerDog kd = new KillerDog;
$kd.name = "Killer Dog";
$kd.weight = 9999;
$kd->out();
var Dog d = $kd;
"And the same:\n";
$d->out();
}