Unknown LNK2019 error

I keep getting these error messages "error LNK2019: unresolved external symbol "public: __cdecl ReadFile::ReadFile(void)" (??0ReadFile@@QEAA@XZ) referenced in function main" & "fatal error LNK1120: 1 unresolved externals" and I'm not sure how to fix it. I'm using visual studios to create the cpp file but I'm using the command prompt to compile it. The specific name is x86_x64 Cross Tools Command Prompt for VS 2017
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
  #include<iomanip>
#include<iostream>
#include<string>
#include<fstream>
using namespace std;

class ReadFile {
private:
	int numbers[1000];
public:
	ReadFile();
	void read(int array[]) {
		ifstream tFile;
		array[1000];
		tFile.open("NumberList.txt");
		for (int i = 0; i < 1000; i++) {
			tFile >> array[i];
		}
		tFile.close();
	};
	void allValues(int array[]) {
		for (int i = 0; i < 1000; i++) {
			cout << array[i] << " ";
		}
	};
	void sumVals(int array[]) {
		int sum = 0;
		for (int i = 0; i < 1000; i++) {
			sum = sum + array[i];
		}
		cout << sum;
	};
	void oddVals(int array[]) {
		for (int i = 0; i < 1000; i++) {
			if (array[i] % 2 != 0)
				cout << array[i];
		}
	};
	void evenVals(int array[]) {
		for (int i = 0; i < 1000; i++) {
			if (array[i] % 2 == 0)
				cout << array[i];
		}
	};
	void midVals(int array[]) {
		cout << array[1000 / 2] << " " << array[1000 / 2 - 1];
	};
	void firstVal(int array[]) {
		cout << array[0];
	};
	void lastVal(int array[]) {
		cout << array[1000 - 1];
	};
	void largestVal(int array[]) {
		for (int i = 1; i < 1000; i++) {
			if (array[0] < array[i]) {
				int temp = array[i];
				array[i] = array[0];
				array[0] = temp;
			}
				
		}
		cout << array[0];
	};
	void smallestVal(int array[]) {
		for (int i = 1; i < 1000; i++) {
			if (array[0] > array[i]) {
				int temp = array[i];
				array[i] = array[0];
				array[0] = temp;
			}

		}
		cout << array[0];
	};
	void sort(int array[]) {
		int temp;
		bool swap;

		do {
			swap = false;
			for (int count = 0; count < (1000 - 1); count++) {
				if (array[count] > array[count + 1]) {
					temp = array[count];
					array[count] = array[count + 1];
					array[count + 1] = temp;
					swap = true;
				}
			}
		} while (swap);
		for (int i = 0; i < 1000; i++) {
			cout << array[i] << " ";
		}
	};
	void search(int array[], int value) {
		int first = 0;
		int last = 1000 - 1;
		int middle;
		int position = -1;
		bool found = false;

		while (!found && first <= last) {
			middle = (first + last) / 2;
			if (array[middle] == value) {
				found = true;
				position = middle;
			}
			else if (array[middle] > value)
				last = middle - 1;
			else
				first = middle + 1;
		}
		if (position == -1)
			cout << "That number is not here" << endl;
		else
			cout << value << " was found in element " << position << " of the array." << endl;
	};
};

int main()
{
	int numberList[1000];
	srand(time(NULL));
	ofstream myFile;
	myFile.open("NumberList.txt");
	for (int i = 0; i < 1000; i++) {
		int temp = (rand() % 1000) + 1;
		myFile << temp << " ";
	}
	myFile.close();
	int choice;
	int numSearch;
	ReadFile numbers;
	numbers.read(numberList);
	//cout << "files have been written.";

	/*ifstream tFile;
	int numbers[1000];
	tFile.open("NumberList.txt");
	for (int i = 0; i < 1000; i++) {
		tFile >> numbers[i];
		//cout << numbers[i] << " ";
	}
	tfile.close();*/
	cout << "What would you like to do" << endl;
	do {
		cout << "1. Output all Values " << endl << "2. Sum of Values" << endl << "3. Output all odd Values" << endl << "4. Output all Even Values" << endl << "5. Output Middle Value"
			<< endl << "6. Output First Value" << endl << "7. Output Last Value" << endl << "8. Output Highest Value" << endl << "9. Output Lowest Value" << endl << "10. Sort & Output Values"
			<< endl << "11. Linear Search" << endl << "12. Exit" << endl;
		cin >> choice;
		switch (choice) {
		case 1:
			numbers.allValues(numberList);
			break;
		case 2:
			numbers.sumVals(numberList);
			break;
		case 3:
			numbers.oddVals(numberList);
			break;
		case 4:
			numbers.evenVals(numberList);
			break;
		case 5:
			numbers.midVals(numberList);
			break;
		case 6:
			numbers.firstVal(numberList);
			break;
		case 7:
			numbers.lastVal(numberList);
			break;
		case 8:
			numbers.largestVal(numberList);
			break;
		case 9:
			numbers.smallestVal(numberList);
			break;
		case 10:
			numbers.sort(numberList);
			break;
		case 11:
			cout << "Enter the value you're looking for";
			cin >> numSearch;
			numbers.search(numberList, numSearch);
			break;
		case 12:
			return 0;
		}

	} while (choice != 12);
}
http://www.cplusplus.com/forum/general/113904/#msg622050
¿where's the body of the `ReadFile()' constructor?


then I'll have to question why do you have `numbers' members variable if you never use it.
your object has no state.

Also
1
2
3
	void read(int array[]) {
		ifstream tFile;
		array[1000]; //out of bounds access, and no operation 
ok problem solved. I forgot to take out the constructor. Thanks, ne555.
Topic archived. No new replies allowed.