Heri ligger dit problem:
BInput == "P" || "p"
(og de 2 andre statements af samme art).
Du sammenligner først en streng med en anden streng/pointer og derefter en pointer/streng med adressen 0 (dvs. koden || "p" returnerer altid sandt).
Denne her virker:
if (BInput == "P" || BInput == "p")
Og her er den tilrettede kode:
void Build::sub_Build()
{
string BInput;
cout << "\\n\\n Press P for Production buildings. \\n Such as Factory or Air Port.\\n";
cout << "\\n Press D for Defeance buildings. \\n Such as Kannon or Missil turrent.\\n";
cout << "\\n Press O for Other buildings. \\n Such as Power plant or Scanner.\\n";
while(1)
{
cin >> BInput;
if (BInput == "P" || BInput == "p") {Build_P(); break;}
else if (BInput == "D" || BInput == "d") {Build_D(); break;}
else if (BInput == "O" || BInput == "o"){Build_O(); break;}
else
{
cout << "\\n Worng letter please try agian.\\n";
}
}
}
1101110100010110000101000001
Killers don't end up in jail - they end up on a high-score!
[Redigeret d. 23/05-05 18:58:15 af Nicolai Lyster Fersner]