I'm a tad curious as to why I have to forward declare a function that I have in a separate file that I've already #included in my header |
No, it does not appear that you included the forward declaration in your header.
It's not clear what's being included where since you did not identify your file names.
snippet 1: I'm presuming this is header.h. There is no forward declaration of login() in this header.
snippet 2: I'm presuming this is main.cpp. This is where you have your forward declaration for login(). Your forward declaration belongs in header.h, not here.
snippet 3: I'm presuming this is login.cpp. Since the forward declaration for login() is not in header.h, the compiler won't detect any mismatch in the function signatures.
snippet 3 line 15: You want an || condition here. If either does not match, you want to fail the login.
Also, you might want to make this a
bool
function since you probably want to return an indication to main that the login failed.
snippet 3 line 18: I'm not a fan of using recursion here. If the user doesn't know the correct user and and password, you're just going to recurse forever. You have no other way out of the program.