Your question isn't completely clear, if you mean testing if more than one condition is true then yes. Using the && (AND) operator, if all of the below conditions are true the statement as a whole will evaluate to true
I'm trying to allow users to select a location(or map) within an if statement. I don't think you can have multiple if statements in on if statement.
Like so:
1 2 3 4 5
cout<< " Please pick a location."<<endl;
cout<< " 1) Nacht der Untoten"<<endl;
cout<< " 2) Verruckt"<<endl;
cout<< " 3) Kino Der Toten"<<endl;
cin>>location;
The piece of code you see above is already contained by an if statement. What I'm asking is: can I add another if statement, within the one I have already.
Please let me know if this is a little more clearer.
The difference is only that depending on the situation one of these may be easier to read (here it's version 2, for more complex conditions it's usually version 1). Also, version 1 allows you to have an else case for each unmet condition. Which can be quite annoying if you have like 20 conditions and check each of these manually (thank C++ for exceptions).
cout<< " Please pick a location."<<endl;
cout<< " 1) Nacht der Untoten"<<endl;
cout<< " 2) Verruckt"<<endl;
cout<< " 3) Kino Der Toten"<<endl;
cin>>location;
switch (location)
{
case 1: cout<< "You slected 'Nacht der Untoten'" ;
case 2:
cout<< "You selected 'Verruckt'"<<endl;
case 3: cout<< "You selected 'Kino Der Toten'" ;}
When the user inputs a number it displays all cases instead of the case it's assigned to. For example, I tested my program and when I got to the map selection, I entered the number 1, and instead of it displaying case 1, it displayed all cases! :(