Reputation: 29
I am getting the error, multiple definition of addOrRemoveCashier(std::string)
with the following codes,using netbeans 7.4
this is what I have
codes
login.h
#ifndef LOGIN_H
#define LOGIN_H
#include <iostream>
class login {
public:
void addOrRemoveCashier(std::string role);
private:
};
#endif /* LOGIN_H */
login.cpp
#include <sstream>
#include <fstream>
#include "login.h"
void login::addOrRemoveCashier(std::string role)
{
if (role == "Administrator")
{
std::cout << " " << std::endl;
std::cout <<"Select a choice!" std::endl;
std::cout << "1) Add New Cashier" <<std::endl;
std::cout << "2) Remove Existing Cashier" << std::endl;
std::cout << "3) Back" << std::endl;
std::cin >> input;
switch ( input )
{
case 1:
//add a cashier
//go back to the system Main menu after adding a cashier
break;
case 2:
//remove a cashier
//go back to the system Main menu after removing a cashier
break;
case 3:
break;
default:
std::cout << "Invalid choice!" << std::endl;
break;
std::cin.get();
}
}
else
{
std::cout << "You don't have access rights" << std::endl;
}
}
main.cpp
#include <iostream>
#include <string>
#include <fstream>
#include "login.h"
inline char caesarDecrypt( char c )
{
if( isalpha(c) )
{
c = toupper(c);
c = (((c+65)-3) % 26) + 65;
}
return c;
}
int main()
{
int attempt = 3;
bool found = false;
int input;
login doAdministration;
std::string line,userName,password,output,userNameInFile,passwordInFile,roleInFile,role;
std::cout <<"----------------------------------"<< std::endl;
std::cout << "Login Page!" << std::endl;
while(attempt)
{
if(attempt != 0)
{
std::ifstream readFile("userandPassword.txt");
std::cout << "Enter UserName: ";
std::cin >> userName;
std::cout << "Enter Password: ";
std::cin >> password;
while (readFile >> userNameInFile >> passwordInFile >> role)
{
output = "";
for(int x = 0; x < passwordInFile.length(); x++)
{
output += caesarDecrypt(passwordInFile[x]);
}
if (userName == userNameInFile && password == output)
{
role = roleInFile;
std::cout << role << std::endl;
std::cout << "Login Successfully!"<< std::endl;
found = true;
std::cout << " " << std::endl;
std::cout <<"Welcome to System Main Menu!"<< std::endl;
std::cout << "1) Administration-Add/Remove Cashier" << std::endl;
std::cout << "2) Logout" << std::endl;
std::cout << "\nEnter your choice" << std::endl;
std::cin >> input;
switch ( input ) {
case 1:
doAdministration.addOrRemoveCashier(role);
break;
case 2:
go back to the Login page;
break;
-
default:
std::cout << "Invalid choice!" << std::endl;
break;
std::cin.get();
}
break;
}
}
if (!found)
{
attempt -= 1;
std::cout << "InValid UserName Or Password"<< std::endl;
std::cout << "Attempts Left: " << attempt<<std::endl;
if(attempt == 0) {
std::cout <<"System LOCKED!";
}
}
if(found)
{
break;
}
}
}
}
please give advice and help thanks
Upvotes: 0
Views: 147
Reputation: 19
Did you even tried to compile login.cpp? In case, you should've seen errors like this one:
std::cout <<"Select a choice!" std::endl;
(missing <<)
Upvotes: 1