Yes, there is a way to have Team Fortress 2 automatically pick a random class for you after you die. This can be set up through the game's console commands or by selecting the random option in the class menu. It is a handy feature if you enjoy mixing things up and letting chance decide which class you play each round.