I didn’t go into that as it was even further off-topic, but since you have brought it up;
the key difference is with inheritance is a Dog
that inherits Animal
IS an Animal
, with composition a Dog
contains Animal
, it is not an Animal
. It’s a big difference but easily overlooked, that translates practically to inheritance being a higher level concept and composition being quite fundamental.
Inheritance is mostly a fault of human thinking, all uses can be practically replaced by composition while making data relationships simpler.