Logical OR isn't working Properly

Hello (: I'm learning C++ obviously and my friend let me borrow his C++ book from school called "Beginning C++ Game Programming". Anyways I'm on Chapter Two and I'm currently learning Logical Operators. For some reason, the Logical OR "||" isn't working on it's current statement, but works on others. Here is what I got:

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
#include <iostream>
#include <string>

using namespace std;

int main()
{
    cout << "\tGame designer's Network" << endl;
    int security = 0;

    string username;
    cout << "\nUsername: ";
    cin >> username;

    string password;
    cout << "Password: ";
    cin >> password;

    if (username == "D.Monte" && password == "bluemountain"){
        cout << "\nWelcome Back King Dustin";
        security = 5;
    }
    if (username == "J.Monte" && password == "mooon7"){
        cout << "\nWelcome Jasmine! You look skinnier today (:";
        security = 5;
    }
    if(username == "guest" || password = "guest"){
        cout << "\nWelcome, guest!";
        security = 1;
    }
    if (!security){
        cout << "\nYour login failed.";
    }

}



So anyways, this is the error...

1
2
3
4
    if(username == "guest" || password = "guest"){
        cout << "\nWelcome, guest!";
        security = 1;
    }


Code::Blocks says:

error: no match for 'operator||' in 'std::operator==<char, std::char_trants<char>


Please help, I am really confused...
Last edited on
password = "guest"

should be

password == "guest"
wow, simple fix. thanks a lot. I need to be more cautious of my errors.
Topic archived. No new replies allowed.