Linker error

Why am i getting this LNK2019 error?

Header:
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
 #include <iostream>

using std::cout; using std::endl;

#ifndef VARARRAY_H_
#define VARARRAY_H_

class varArray{
public:
	varArray(); // void constructor
	int arraySize() const { return size; } // returns the size of the array

	int check(int number); // returns index of element containg "number" or -1 if none
	void addNumber(int);    // adds number to the array
	void removeNumber(int); // deletes the number from the array
	void output();      // prints the values of the array

	// big three
	varArray(const varArray&); // copy constructor
	varArray& operator=(const varArray&); // overloaded assignment
	~varArray(); // destructor

private:
	int *dArray; // pointer to the dynamically allocated array
	int size;   // array size
};

#endif /* VARARRAY_H_ */ 


Code to test functions:
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
 #include "vararray.h"

void testfunc(varArray); // function to test pass-by-value for varArray

int main(){

	varArray a1;

	// testing regular member functions
	a1.addNumber(1);
	a1.addNumber(2);
	a1.addNumber(3);
	a1.addNumber(3); // trying to add duplicate, should not add it
	
	cout << "array size is: " << a1.arraySize() << endl;

	if (a1.check(1) != -1) // check() returns -1 if number not present
		cout << "1 is present in the array" << endl;

	if (a1.check(5) != -1)
		cout << "5 is present in the array" << endl;

	a1.output();
	a1.removeNumber(2);
	a1.output();

	/* // uncomment this when you debugged the first part
	varArray a2,a3;

	a3=a2=a1; // testing overloaded assignment
	a3=a3; // testing protection against self-assingment

	testfunc(a3); // testing copy constructor
	a3.output(); // if destructor is implemented correctly
	// this should print properly after testfunc completes
	*/
}

/*
// tests pass-by-value for object of class varArray
void testfunc(varArray va){ // copy constructor is invoked on "va"
va.output();
} // destructor is invoked when "va" goes out of scope
*/


Function definitions:
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
 #include "vararray.h"

void varArray::addNumber(int x){
	if (check(x) != -1)
		return;
	int* ptr;
	ptr = new int[size + 1];

	for (int i = 0; i < size; i++) {
		ptr[i] = dArray[i];
	}
	ptr[size] = x;

	delete[] dArray;
	dArray = ptr;
	size++;
}

int varArray::check(int number){
	for (int i = 0; i < size; i++){
		if (dArray[i] == number)
			return i;
	}
	return -1;
}

void varArray::removeNumber(int number){
	int* ptr;
	ptr = new int[size - 1];
	int ptrcounter = 0;
	for (int i = 0; i < size; ++i){
		if (dArray[i] != number) {
			ptr[ptrcounter] = dArray[i];
			ptrcounter++;
		}
	}
	delete[] dArray;
	dArray = ptr;
	size--;
}

void varArray::output(){
	int* ptr;
	int tempsize = size;
	ptr = new int[size];

	for (int i = 0; i < size; i++) {
		ptr[i] = dArray[i];
	}
}
Please post the full text of your linker error.
1>------ Build started: Project: Lab11_VarArrayTest, Configuration: Debug Win32 ------
1> vararray.cpp
1> test.cpp
1> Generating Code...
1>test.obj : error LNK2019: unresolved external symbol "public: __thiscall varArray::varArray(void)" (??0varArray@@QAE@XZ) referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol "public: __thiscall varArray::~varArray(void)" (??1varArray@@QAE@XZ) referenced in function _main
1>C:\Users\Freddie Mo\documents\visual studio 2013\Projects\Lab11_VarArrayTest\Debug\Lab11_VarArrayTest.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
header line 10: You declare a default constructor, but provide no implementation for it.

header line 21: You declare a destructor, but provide no implementation for it.
Topic archived. No new replies allowed.