'X' not declared in this scope Error, HELP

Oct 29, 2014 at 7:06pm
closed account (ywTRfSEw)
main.cpp

#include <iostream>
#include "sushi.h"
using namespace std;

int main()
{
do{
......sushi go;
......string x; <----------------------------Declared x here
......cout << "wanna use a banana?" << endl;
......cin >> x;
...if (x=="yep"||x=="OK"||x=="yes"||x=="y"||x=="yeah"){
......go.math();
......go.BANANA();
...}else{
......cout << "you son of a ...";
......}
...}while (x==!"yep"||x==!"OK"||x==!"yes"||x==!"y"||x==!"yeah");<----error here
...return 0;
}

Error reads: 'x' was not declared in this scope. How do I fix this?

P.S The sushi class does not matter, that is all perfect. Also, the dots are to represent my tabbing to make it easier to understand.
Oct 29, 2014 at 7:13pm
does this work?
#include <string>
Oct 29, 2014 at 7:17pm
Instead of using dots, try clicking the "<>" format button and pasting your code between the tags that it inserts.

Move the declaration of x outside the do loop. The while is outside the scope of the do loop, so x is not defined.

Also, what is x==!"yep"? I don't even know how ! interacts with a string. Were you trying to do x != "yep"?
Topic archived. No new replies allowed.