Help with template classes and error LNK2001

Hi all!

I have some error LNK2001s due to this class, but I am not too good with templates:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// pro_vector.hpp
namespace pro {

template<class T>class vector {
public:
	vector();
	vector(T x, T y);
	~vector();
	void setX(T x);
	void setY(T y);
	T &getX();
	T &getY();
private:
	T x;
	T y;
};

}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//pro_vector.cpp
#include "pro_vector.hpp"

using namespace pro;

template<class T> vector<T>::vector() {

}

template<class T> vector<T>::vector(T x, T y) {
	this->x = x;
	this->y = y;
}

template<class T> vector<T>::~vector() {

}

template<class T> void vector<T>::setX(T x) {
	this->x = x;
}

template<class T> void vector<T>::setY(T y) {
	this->y = y;
}

template<class T> T &vector<T>::getX() {
	return x;
}

template<class T> T &vector<T>::getY() {
	return y;
}


If anyone could tell me where I went wrong or what I should not do, I would be grateful!
Combine the header file and the module in one header file.
so put everything from pro_vector.cpp into the header and remove the .cpp file?
Yes, you are right.
Hey thanks man it worked! :D
I owe you one.
Topic archived. No new replies allowed.