Trouble trying to include another header file

I am exploring with using the implementation and separating my code into different header and source files. I have a class Security that is defined in security.h and then shows the definition in security.cpp. I am trying to have two other classes administrator and user that will each have their own login function which will utilize a function in from the security class. I began coding the administrator class and found that I could not use the function from the security class even though I had used #include"security.h".Anyway, it's probably a simple problem but I cant seem to figure it out, below is the security class header file and implementation file and administrator implementation file.

security.h
1
2
3
4
5
6
7
8
9
10
11
12
  #pragma once
#include<iostream>
#include<cstdlib>
#include<string>
using namespace std;

class Security
{
public:
	static int validate(string username, string password);
};

security.cpp
1
2
3
4
5
6
7
8
9
#include"security.h"
using namespace std;

int Security::validate(string username, string password)
{
	if ((username == "abbott") && (password == "monday"))return 1;
	if ((username == "costello") && (password == "tuesday")) return 2;
	return 0;
}

administrator.cpp
1
2
3
4
5
6
7
8
#include"administrator.h"
#include"security.h"
using namespace std;

bool Administrator::Login(string username, string password)
{
	validate(username, password);
}
1
2
3
4
5
6
7
8
#include"administrator.h"
#include"security.h"
using namespace std;

bool Administrator::Login(string username, string password)
{
	Security::validate(username, password);
}


static functions in a class require the class name to be used in invocation (unless invoked within a method of that class.) Non-static functions require an instance to operate on.
Last edited on
Awesome! Thanks that's a big help! I was trying to mess around with #ifndef and nothing was happening thank you
Topic archived. No new replies allowed.