Early trains didnt have heating. Later on they equipped the carriages with coal stove. Then came the time when steam heaters were developed. These were supplied by the locomotive - one simply tapped from the steam that was available in the steam locomotive anyway.