This is assuming the zombies are the ones from World War Z or George Romero's Dead Series.
Heavy - Good at mowing down the masses, but it's the precise head shot through the cranial dome that makes the zombie stay down. Even if you cut them in half with a burst from Sasha, the zombies will still just crawl towards you and bite your ankle when you're not paying attention. Also, the noise of a chain gun will just attract more zombies.
Scout - Zombies don't really walk, they hobble, so the scout would be able to outrun them. Still, fatigue would eventually catch up so unless you know where you're running to, you're worse off than where you started (in terms of hiding spots).
Engineer - The engineer would be great at turtling with his turrets, but if ammo, food or water were limited, his hiding spot would do for only so long.
Pyro - Fire would eventually kill a zombie, but only after having sufficiently cooked the brain. The muscles in the limbs would fail first, but the Z would get a few last steps in before falling. On a global scale, if everyone started fighting zombies with fire, we'd get stuck in a protracted winter season from the smoke blocking out the sun.
Sniper - If stocked up on food and water, a sniper's nest could be the safest place on the planet. Since zombies don't climb, all you have to do is wait for rescue. Drawback: if no rescue comes, and you've been sniping zombies for the last few days, the sound of your gunfire is going to attract a pretty massive horde. If your supplies run out before rescue, your sniper's nest will be you coffin.
Soldier - Shovels are one of the best close range weapons to use against the Zs. A well placed crack to the skull will put them down. The best melee weapons against zombies are those that have multiple uses (ie crowbars, shovels, sledgehammers) for breaking down doors or digging graves.
Spy - The worst thing you can do is to try to immitate the zombies. I think they were called Quislings in World War Z. Pretty much a death sentence right there. The real zombies will know you're faking and eat you.
Demoman - Explosives will work well against large groups of zombies, but bare in mind that the sound of the explosions will attract more Zs.
Medic - Kinda worthless in treating the bites and scratches from the zombies, but essential in treating the injuries that slow you down. (ie broken legs or sprained ankles) Don't try and find a cure; just survive.
Good hunting, hope to see you guys Post-Zombie Uprising.