Driving me crazy keep getting "this line contains a '{' which has not yet been matched on several lines even though i cant find where there missing.
thanks
main.cpp
#include <iostream>
#include <string>
#include "USER.h"
using namespace std;
string Get_password();
string Get_username();
void Open_account_sucess();
void Error();
void Exit();
void Wrong_pass();
bool chk_input(User,User);
int main()
{
bool is_exit = 0;
string Password;
string Username;
User Fred(Preset_username,Preset_password,"FRED JOHNSON");
User Temp(" "," ","guest");
while(is_exit == 0)
{
//string user ;
int user = 0;
cout<<"[TERMINAL LOGIN]"<<endl;
cout<<"1.Log into terminal \n2.Exit"<<endl;
if(cin>>user == 0)
{
cin.clear();
cin.ignore(1000,'\n');
}
else if (user == 2)
{
is_exit = 1;
Exit();
continue;
}
else if(user <0 || user <2)
{
cout<<"incorrect choice"<<endl;
cin.get();
}
else if(user ==1)
{
Temp.Password = Get_password();
Temp.Username = Get_username();
/////
bool credential_result = chk_input(Temp,Fred);
if(credential_result == 1)//suceess
{
Open_account_sucess();
cout<<"welcome "<<Temp.get_account_data(NAME)<<endl;
continue;
{
}
system("cls");
}
return 0;
}
bool chk_input(User Currentuser,User Storeduser)
{
int result;
if(Currentuser.Username.compare(Storeduser.get_account_data(USERNAME)) == 0 && Currentuser.Password.compare(Storeduser.get_account_data(PASSWORD)) == 0 )
{
result = 1;
}
else if (Currentuser.Username.compare(Storeduser.get_account_data(USERNAME)) == 1 && Currentuser.Password.compare(Storeduser.get_account_data(PASSWORD)) == 0 )
{
Print_incorrect_credentials(USERNAME);
result = 0;
}
else if (Currentuser.Username.compare(Storeduser.get_account_data(USERNAME)) == 0 && Currentuser.Password.compare(Storeduser.get_account_data(PASSWORD)) == 1 )
{
Print_incorrect_credentials(PASSWORD);
result = 0;
}
else
{
cout<<"Both credentials are incorrect "<<endl;
result = 0;
}
return result;
}
string Get_password()
{
string temp;
while (temp.empty())
{
cout<<"Enter-password->>>"<<endl;;
cin>>temp;
}
return temp;
}
string Get_username()
{
string temp;
while (temp.empty())
{
cout<<"Enter-username->>>"<<endl;;
cin>>temp;
}
return temp;
}
void Open_account_sucess()
{
cout <<"account opened succesfully "<<endl;
cin.get();
}
void Error()
{
cout <<"A input error occured"<<endl;
cin.get();
}
void Print_incorrect_credentials(int error_id)
{
if(error_id == PASSWORD)
cout <<"Wrong_pass"<<endl;
else if(error_id == USERNAME)
cout <<"Wrong_username"<<endl;
else
cin.get();
}
void Exit()
{
cout<<"exiting"<<endl;
cin.get();
}
USER.h
#include <string>
using namespace std;
enum
{
PASSWORD,
USERNAME,
NAME
};
const string Preset_password = "pass";
const string Preset_username = "fred10";
class User
{
string Name;
public : string Username;
string Password;
public:
User(string username,string password,string name);
string get_account_data(int data_id);
};
USER.cpp
#include "USER.h"
User::User(string username,string password,string name)
{
this->Username = username;
this->Name = name;
this->Password = password;
}
string User::get_account_data(int data_id)
{
string data;
switch(data_id)
{
case PASSWORD:
data = this->Password;
break;
case USERNAME:
data = this->Username;
break;
case NAME:
data = this->Name;
break;
default:
data = "error";
break;
}
return data;
}