You can sleep in the train.. Night trains do have normal seats, couchettes (something like a bed) and real beds. Seats are not really comfortable, but I think it's good enough! Sometimes you must pay extra for them (cheaper than most youth hostels/campsites).
Couchettes are very good! you'll sleep well and in Germany the train personnel will get you out of your sleep, 30 min. before arriving. They are a bit more expensive, but it's worth it!
I never tried the real beds, because they are very expensive (including a breakfast
) and the couchettes are good enough for me.
More details about all night trains in Europe: rail.cc/en/interrail-night-train
Enjoy your trip and sleep well!