Answer: 240m
This is why I love running a puzzle website: I learn clever ways to solve puzzles from reading the various solutions that are offered.
The most common way to solve this puzzle is to set up two simultaneous equations with three (or more) unknowns. Several of the unknowns drop out, because they are proportional to one another, leaving the length of the train.
The second most popular method is the one I used (see below), which is to note that the ratio of the distances walked by the two people is 3:4, so the ratio of length-30 to length+40 is also 3:4.
The third method, which was only used by a few people, was to note that the forward-walking person traveled 10m while the tail of the train passed from one person to the other, a distance of 70m, so the ratio of waking speed to train speed is 1:7, so length-30=7*30 and length+40=7*40, either one of which will give the answer.
Dense13 provided the best method: He noted that 60m of train was behind the forward-walking person when he had walked 30m, and that 60m passed him during the time he walked 10 more meters.
So, for every 10m he walked, 60m of train passed him. Since he walked 40m in all, the total length of the train that passed him is 240m.
Now here's how I solved it:
Let d be the length of the train, and
let t1 be the time it took for the tail of the train to reach
the first person, and
let t2 be the time it took for the tail of the train to reach
the second person.
By time t1, the head of the train is d-30 meters beyond the point where it passed the two people.
By time t2, the head was d+40 meters beyond where it passed the two people. The ratio of these distances,
d-30 : d+40
is equal to the ratio of t1:t2, because the train is moving at a constant speed.
Since both people walk at the same constant rate, this ratio is 3:4.
d-30 : d+40 = 3:4
The product of the means equals the product of the extremes, so
3(d+40) = 4(d-30)
3d + 120 = 4d - 120
240 = d