For your own clarity and those who are to read you code, please format it properly. If you use tabs in your editor, it most likely offers a feature to replace those with 4 spaces.
So instead of:
Code:
int main()
{
cout <<
"Hello World!"
<< endl;
}
... consider:
Code:
int main()
{
cout << "Hello World!" << endl;
}
You get the idea.
While user_pass and pass_checker might be able to access your variables, this is due to them being declared globally. I would advise against doing this, as it is considered back practice in most cases and makes your program harder to reason about. So declare username and password locally inside main in your example.
Using functions involves learning about passing variables to them. So before rushing into this, I suggest you consult the web on how to do that.
If you want to use pass_checker as a condition for an if statement, it should return a bool value.
Code:
bool pass_checker(const string& username, const string& password)
{
return (username == "root" && password == "1") || (username == "beer" && password == "2");
// ^ returns the outcome of your expression; either true or false.
}