Hello,

I have a function similar to this for character construction (types omitted).

The switch statement does not work. I though it is an issue of score, but setting curly brackets inside each case does not help. The actual switch statement is quite long, because there are many admissible combinations of weapons (and more than two weapons are allowed).

Can you please help with an advice? Thanks!

Code:
CowboyPtr ConstructCowboy(std::string name, const int loadoutcode)
{
	CowboyPtr cowboy = CowboyPtr(new Cowboy(name));
	switch (loadoutcode) {
		default:
		WeaponPtr leftweapon = WeaponPtr(new Colt());
		WeaponPtr rightweapon = WeaponPtr(new Whip());
		break;
		case 1:
		WeaponPtr leftweapon = WeaponPtr(new Colt());
		WeaponPtr rightweapon = WeaponPtr(new Rifle());
		break;
	}
	cowboy->Loadout.insert(WeaponPair(leftweapon->Range, leftweapon));
	cowboy->Loadout.insert(WeaponPair(rightweapon->Range, rightweapon));
	return cowboy;
}