Undefined reference to class::function

I have three files: Main.cpp, Security.h, and Security.cpp. I have declared my class Security (including a function) in my header file. I have defined the function in Security.cpp. In Main.cpp, I'm creating an object, and attempting to run the member function and keep getting a compile error.


Main.cpp

1
2
3
4
5
6
7
8
9
10
11
#include<iostream>
#include "Security.h"

using namespace std;


int main()
{
  Security S1;
  S1.Driver();
}



Security.h

1
2
3
4
5
6
7
class Security
{private:


 public:
  void Driver();
};


Security.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include<iostream>
#include<fstream>
#include "Security.h"

using namespace std;

void Securtiy::Driver()
{
  cout << "Enter a number: ";
  int answer;
  cin >> answer;

  cout << answer;
}

typo in Security.cpp
void Securtiy::Driver()


In the future, giving the compile error would of given away the problem, so we dont have to run it, also giving another chance for you to of caught the typo.
Last edited on
Typo? void Securtiy::Driver()

It is best to post the actual compiler error.
Topic archived. No new replies allowed.