Somehow, I'm doing it wrong (again).
program mwe;
{$mode objfpc}
type
vehicle = class
private
wheelCount: word; static;
end;
car = class(vehicle)
end;
bus = class(vehicle)
end;
begin
car.wheelCount := 4;
bus.wheelcount := 6;
writeLn('Cars have ', car.wheelCount, ' wheels.');
writeLn('Busses have ', bus.wheelCount, ' wheels.');
end.
Why do both cars and busses end up having six wheels? I thought at the end of the inheritance tree you tie all ancestor definitions and methods together to
one independent type. However here both leaves don't exist on their own. Their shared ancestor does not become part of their definition, but is just referenced.
I'm looking for an explanation here. I guess generics are a solution in my case.