C++ | Syntax Error: Identifier 'i' -
hey guys, i'm pretty sure else has had problem too, couldn't find related problems. stupid typo or something, i'm not able figure out >.<
what's wrong code, error:
error c2061: syntax error : identifier 'i'
#include <iostream> #include <string> using namespace std; class mahinluokka { public: void setnum(int); int getnum(); private: int mahi_num; }; int main() { int i; { cout << "insert number between 1-100" << endl; cin >> i; } while > 100 || < 0; mahinluokka mahi; mahi.setnum(i); cout << mahi.getnum() << endl; mahi.setnum(5); cout << "mahi_num set 5" << endl; cout << mahi.getnum() << endl; // end int x; cin >> x; return 0; } void mahinluokka::setnum(int number) { mahi_num = number; } int mahinluokka::getnum() { return mahi_num; }
you need enclose conditions in parentheses. in other words, change this:
} while > 100 || < 0;
to this:
} while(i > 100 || < 0);
Comments
Post a Comment