Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions