linker error to static variables?

i defined a class like this in the header
1
2
3
4
5
6
7
8
9
10
11
12
	class sortAlgorithm {
	public: 
		static void bubblesort(dataSorter container);
		static void mergesort(dataSorter container);
		static void combsort(dataSorter container);
		static void quicksort(dataSorter container);
	private:
		static int length;
		static int sweep;
		static int depth;
		static int temp;
	};

and when i try to compile i get these errors

1>test data.obj : error LNK2001: unresolved external symbol "private: static int testData::sortAlgorithm::temp" (?temp@sortAlgorithm@testData@@0HA)
1>test data.obj : error LNK2001: unresolved external symbol "private: static int testData::sortAlgorithm::depth" (?depth@sortAlgorithm@testData@@0HA)
1>test data.obj : error LNK2001: unresolved external symbol "private: static int testData::sortAlgorithm::sweep" (?sweep@sortAlgorithm@testData@@0HA)
1>test data.obj : error LNK2001: unresolved external symbol "private: static int testData::sortAlgorithm::length" (?length@sortAlgorithm@testData@@0HA)

can i get a hint to what i did wrong?
i should also note that i am using vc++ 2008
You need to instantiate the objects in a translation unit, e.g.

int sortAlgorithm::length;

However, it seems you're misusing classes as namespaces, so use a namespace instead.
thank you, that solved the issue
Topic archived. No new replies allowed.