Question
Having fixing and error in my code: Security.cpp:8:11: error: C++ requires a type specifier for all declarations Security::validate(const char *userName, const char *password) ^ Security.cpp:7:62:error:ISO
Having fixing and error in my code:
Security.cpp:8:11: error: C++ requires a type specifier for all declarations Security::validate(const char *userName, const char *password) ^
Security.cpp:7:62:error:ISO C++ forbids declaration of validate with no type [-fpermissive]
Security::validate(const char *userName, const char *password)
^
Security.cpp:7:1:error:prototype for int Security::validate(const char*, const char*) does not match any in class Security
Security::validate(const char *userName, const char *password)
^
In file included fromSecurity.cpp:2:0:
Security.h:17:5:error:candidate is: static credentials Security::validate(const char*, const char*)
validate(const char *userName, const char *password);
Code:
Security.h
#ifndef SECURITY_H
#define SECURITY_H
#include
#include
using namespace std;
enum credentials {invalid, user, administrator};
class Security{
public:
static enum credentials
validate(const char *userName, const char *password);
};
enum credentials;
#endif
Security.cpp
#include
#include
#include \"Security.h\"
using namespace std;
Security::validate(const char *userName, const char *password)
{
if ((strcmp(userName, \"abbott\") == 0) &&
(strcmp(password, \"monday\") == 0)) {
return(user);
}
if ((strcmp(userName, \"costello\") == 0) &&
(strcmp(password, \"tuesday\") == 0)) {
return(administrator);
}
return(invalid);
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started