Weird linker unresolved external symbol errors

For some reason the code below is throwing these linker errors:
1>main.obj : error LNK2001: unresolved external symbol "public: __cdecl Array::DArray<int>::~DArray<int>(void)" (??1?$DArray@H@Array@@QEAA@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: void __cdecl Array::DArray<int>::set(int,...)" (?set@?$DArray@H@Array@@QEAAXHZZ)
1>main.obj : error LNK2001: unresolved external symbol "public: int __cdecl Array::DArray<int>::get(...)" (?get@?$DArray@H@Array@@QEAAHZZ)
1>main.obj : error LNK2001: unresolved external symbol "public: __cdecl Array::DArray<int>::DArray<int>(void)" (??0?$DArray@H@Array@@QEAA@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: __cdecl Array::DArray<int>::DArray<int>(int,...)" (??0?$DArray@H@Array@@QEAA@HZZ)

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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
  DArray.h:

#pragma once
#include "stdarg.h"
namespace Array {
	template<class T>
	class DArray {
	private:
		T* elements;
		int dimensions;
		int length;
		int* lengths;
	public:
		DArray();
		DArray(int dimensions, ...);
		T get(...);
		void set(T value, ...);
		~DArray();
	};
}

DArray.cpp:

#include "DArray.h"
using namespace Array;

template<class T>
DArray<T>::DArray() {
}

template<class T>
DArray<T>::DArray(int dimensions, ...) {
	//content here not purposeful to the question
}

template<class T>
T DArray<T>::get(...) {
	//content here not purposeful to the question
}

template<class T>
void DArray<T>::set(T value, ...) {
	//content here not purposeful to the question
}

template<class T>
DArray<T>::~DArray() {
        //content here not purposeful to the question
}

StdAfx.h:

#pragma once
#include "DArray.h"

//generates a 2 dimensional matrix of somewhat random integers
Array::DArray<int> generateRandomMatrix(int columns, int rows);
//entry point
int main();

Main.cpp:

#include "stdafx.h"
#include <iostream>

using namespace std;
using namespace Array;

//entry point
int main() {
	int x, y;
	DArray<int> matrix1, matrix2;
	do {
		matrix1 = generateRandomMatrix(10, 5);
		matrix2 = generateRandomMatrix(2, 6);
		for (y = 0; y < 5; y++) {
			for (x = 0; x < 10; x++)
				printf("%d", matrix1.get(x, y));
		}
		for (y = 0; y < 6; y++) {
			for (x = 0; x < 2; x++)
				printf("%d", matrix2.get(x, y));
                }
		printf("\n\nPress Enter to restart...\n");
		getchar();
	} while (true);
	return 0;
}

//generates a 2 dimensional matrix of somewhat random integers
DArray<int> generateRandomMatrix(int columns, int rows) {
	return DArray<int>(columns, rows);
          //not actual code, just wrote this to cut things short
}


5 Linker Errors stating that I did not properly define the contents of the methods defined in DArray.h. I tried removing the #pragma once directive but to no avail. Any help?
I have tried the solutions presented in the forums above, unfortunately Visual Studio issues an even stranger error:

fatal error C1001: An internal error has occurred in the compiler.

1>c:\users\mathusum\desktop\personal programs\c++ programs\assignment\question6\darray.cpp(26): fatal error C1001: An internal error has occurred in the compiler.
1> (compiler file 'f:\dd\vctools\compiler\utc\src\p2\main.c', line 211)
1> To work around this problem, try simplifying or changing the program near the locations listed above.

where line 211 points to: 'va_start(args, dimensions);' in get()

This is the new header of main.cpp
#include "stdafx.h"
#include <iostream>
#include "DArray.cpp"

The error is confusing, and I'm currently browsing to find a solution to the error.
Last edited on
Topic archived. No new replies allowed.