Undefined reference for included class

I am writing some C++ implementations which work if I inline all the functions into one file, but I would like to "graduate" to using includes. I have followed some different tutorials but in writing my own minimal working example I cannot figure out my mistake. The error I get is always undefined reference, in this case "undefined reference to tester::test(int)":

cppIncludeTest.cpp
1
2
3
4
5
6
7
8
#include <iostream>
#include "tester.h"
using namespace std;

int main() {
	tester::test(5);
	return 0;
}


tester.h
1
2
3
4
5
6
7
8
9
10
11
12
13
#ifndef TESTER_H_
#define TESTER_H_

class tester {

public:

	static void test(int x);

};


#endif /* TESTER_H_ */ 

tester.cpp
1
2
3
4
5
6
7
8
#include "tester.h"
#include <iostream>

void test(int x) {

	std::cout << x << std::endl;

}

In your 'tester.cpp' file, you haven't implemented the classes functions: You need to scope the function. Here is what you probably meant:
1
2
3
4
5
6
#include <iostream>
#include "tester.h"

void test::test(int x) {
    std::cout << x << std::endl;
}
That is the answer thank you!
Topic archived. No new replies allowed.