Temporary HPs function exactly as normal HPs, except that they are designed to be lost first, before applying residual damage (if any) to your normal hit points. They are not to be mistaken for damage resistance, which is the ability to halve the damage taken in some situations, or damage reduction, which is the ability to reduce the damage taken by a fixed amount. All of them, however, should stack.
Player's Handbook (p.198)
When you have temporary hit points and take damage, the temporary hit points are lost first, and any leftover damage carries over to your normal hit points. For example, if you have 5 temporary hit points and take 7 damage, you lose the temporary hit points and then
take 2 damage.
If you possess some form of damage reduction, like the Heavy Armor Master feat, or some form of damage resistance, like the rage ability, you apply these effects first, just like you would when receiving damage normally (remember that, as per the rules, damage resistance is the last modifier to be applied to damage taken). In effect, temporary HPs are a way to magically augment your ability to take punishment.
Contrast this situation with an abjurer's Arcane Ward. In this ability's description, the ward is described as a separate construct having it's own set of HPs, rather than giving you temporary HPs. As such, one could possess both an Arcane Ward AND temporary HPs (although temporary HPs from different sources still wouldn't stack), but the ward shouldn't, at least according to RAW, benefit from damage reduction or resistance effects. Indeed, it is not you taking the damage, at least until the ward breaks.