I'm personally inclined to say that only the demoman, soldier and possibly medic are classes that are useable in any situation. The rest of the classes are more specialized. Engineers shine on CTF and assault maps, but do horribly on mirrored CP maps, conversely, the Scout is much more useful in any map where the Engineer cannot successfully establish himself. The Heavy is a bit more well rounded, but can lag behind if a match ends up being faster paced. The Sniper, like the Engineer, seems to do better on more static maps with less areas of focus (2 intel points rather than roaming active control points) but such is not the case. These factors vary widely from map to map, considering map type, availibility of enclosed indoor spaces, wide open outdoor/indoor spaces, map layout and other factors.
Another factor to take into consideration is the willingness of a team to cooperate ... medics, heavies and engineers are all classes that both derive and contribute greatly to orgainzed teamplay to a greater degree than other classes. While all classes perform better when a team cooperates, the effect is magnified depending on which class you play. You can still do very well as a sniper or soldier even if your team is disorganized or indavidualized, but being an effective engineer or medic becomes much more difficult under the same situations.
This is interesting ... somthing commonly seen on the TF2F (and I'm willing to wadger other servers) is the 'team stack' effect, where one side greatly outperforms another. Part of this is due to genuine stacking of players familiar with each other, part of this is a collective difference in skill levels on teams. However, take a hypothetical example of a match of all players of equal skill level on an indavidual level ... the team more willing to coordinate will generally win more often. I'm of the opinion that the teamwork of a team, rather than the collective differences in skill, will have more of a 'teamstack' effect. I got to see this play out on SteamTV in a scrim between TF2F and another clan ... the opposing clan clearly had some incredibly skilled players, however TF2F was able to pull out a narrow win, despite loosing on point totals, simply because they were more coordnated (the skill differences were stark for two players in paticular, a demoman and a sniper).
It's frustrating for a player such as myself, who prefers a specialized class such as the Engineer, but I'm coming to realize that different maps may occasionally demand vastly different class layouts.