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:

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 from Security.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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!