first off some introduction I have extremely basic c++ programming experience. I
am currently taking a game programming class as an elective in high school but
we have moved from C++ to Game Maker which to me seemed like learning to write
a book and then saying instead of writing a book lets use someone elses writing
to make the book and draw some pictures to go along with it...
anyway i am currently done with AP testing and decided to get back in to c++
because it seemed like it had so much to offer.
so that is why i am here. I have hit a roadblock early on in my program and
need some help with strings in the hierarchy section
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
// login with username & password
#include <iostream>
#include <string>
using namespace std;
// program variables
string beta;
int privelage;
//program start sequence
int programstart ()
{
int alpha;
cout <<"\t Password Program" << endl;
cin >> alpha;
}
// end start sequence
// Hierarchy
int hierarchy ()
{
// set privelage for usernames
if (beta = 'root')
{
privilege = 0;
}
else if (beta = 'wasing')
{
privilege = 1;
}
else if (beta = 'guest')
{
privilege = 2;
}
else
{
privilege = 3;
}
}
// End Hierarchy
//Clear Screen
int screenclear ()
{
cout << string(50, '\n');
}
// Pause the Screen
int screenpause ()
{
int alpha;
cout <<" Press Enter to Continue... "<< endl;
cin >> alpha;
}
// main program
int main ()
{
programstart ();
hierarchy ();
screenclear ();
screenpause ();
return 0;
}
|
i am trying to set up the fuction so that when you type in "root" your
privelage for the program is zero however i am using dev c++ (what we used in
school) and it returned
"27 Login Program.cpp could not convert `(&x)->std::basic_string<_CharT, _Traits, _Alloc>::operator= [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((const char*)"root"))' to `bool' "
which to me means it was trying to convert the string into a true or false
value. if you can show me what i am doing wrong it would be highly appreciated
thank you for your time,
Wa Sing