Hard counter, not maybe this will work before my head is gone.
Alright, let's do the math then.
Standard melee weapons do between 43 and 87 damage per hit. The sword does not crit unless you've charged at them, otherwise it does non-crit damage always.
So any person meleeing the demo with their normal melee weapon will do the same amount of damage the demo does plus have about a 20% chance of critting. Crits will kill the demo in one hit unless he's up over the 4 head limit.
Let's say a sniper and a demo melee fight. The demo has between 150-210 life and the sniper has 125.
In this fight, the demo will need 2 - 3 hits to kill the sniper.
The sniper will need 3-5 hits to kill the demo (with 210 life) without a crit. If the demo is at 0 heads, then the sniper needs 2-4 non-crit hits.
There are two outcomes to this fight: demo wins or sniper wins.
Demo has a 33% - 50% chance of winning against a sniper.
Sniper has a 20% - 50% chance of beating the demo with no crits.
Sniper has a 40% - 70% chance of beating the demo with one crit.
This can be applied to other classes by lowering the Demo's chances of winning in a melee battle relative to the enemy health. Heavies will have the best chance due to the 300 life. which lowers the demo's chances of winning to 14% - 25%.
Now then, if you calculate the odds for the soldier's shotgun, the soldier will kill the demo in two shots at melee range, barring crits. One hit with a crit. That gives the soldier a 50% - 100% chance of beating the demo, while the demo only has a 20% - 33% chance.
All of these figures take into account the fact that both people hit simultaneously, while facing each other with no surprise hits, dodging, or charge crits. Skill modifies all these percentages. More skill = more chance of killing the enemy. But if you're looking at the way the weapons act, then this is what'll happen to two people of equal skill trading hits at the exact same moment.
SCIENCE!