That's one big can of worms you've gone and opened there
I'm not sure I can answer that because even in the tiny UK there are many regional interpretations, as
Yorky has mentioned.
The term 'pudding' is interchangeable with dessert or sweet (depending on the region) as a generic term to describe the sweet course eaten after a main course. In this context, ice cream could be called pudding, for instance.
More specifically, a pie is topped with pastry - shortcrust or puff, whereas a pudding generally isn't. Dishes that involve suet, such as my apple top hat, or sponge, bread etc. would never be called pies - they are puddings. Puddings are generally stodgy type things, so a piece of gateau would not be a pudding, although you may eat it for pudding. Getting clearer?
I will now wait for the rest of the UK to point out that I have got it completely wrong!