Linking error using a class list.

I recieved the error

"1>List.obj : error LNK2019: unresolved external symbol "public: void __thiscall list::resetlist(void)" (?resetlist@list@@QAEXXZ) referenced in function _main"

for every single function contained in my class named "list" in my .h file when I tried to build the solution. It says "LNK", which I assume means a link error.

I don't know why, it seems like I did everything alright.

here's my .h file

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
/*

SPEC file. This file gives the specifications of a list data type. 

*/

#include <string> 

const int maxsize = 100; // maximum number of components.


typedef int itemtype; 

// type of each component... an int every time? how? 

//Because the functions who actually need the type of data all accept the data in the database; ints.

class list
{
public:
	list();

	// constructor, defined in the .cpp file, it makes an empty list.

	void insert(itemtype item);
	
	// if list is not full (that item doesn't take up the 100th space), item is in the list and LENGTH of list increases

	// where length is the number of spaces used

	void deleteitem(itemtype item); // "delete" is a reserved word

	// a given item is removed from the list, is the length subtracted by one? I'm not sure.... I think that's assumed.

	void resetlist();
	// the current position is reset to the first position.

	itemtype getnextitem();
	
	// resetlist() is called if an insert or delete has happened
	// hasnext() needs to run to tell it if there is something coming after the current value.

	bool hasnext() const;

	// tells if there is an entry after the current one in the list.

	bool isempty() const;
	
	// returns true if the list is empty

	bool isfull() const;

	// returns true if the list is full

	bool isthere (itemtype itemname) const;

	// returns true if an item of type _itemtype_ of value _itemname_ is in the list.

	int getlength() const;

	// returns length of list.

private: // why does this need to be private?

	int length;
	int currentpos;
	itemtype data[maxsize]; // the array of length maxsize = 100

};


and my .cpp file

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
// it reads the temperatures from a file and ignores duplicates. It ignores high temperatures and deletes only 1337.


#include <string>
#include <fstream>
#include "list.h"
#include <iostream>

using namespace std;

int main()
{

	ifstream sourcefile;
	ofstream output;


	string filename;

	cout << "imput the name of the file where the temperature data is" << endl << '(';

	cin >> filename;

	sourcefile.open(filename.c_str());
	output.open("output.txt");

	if (!sourcefile)
	{
		cout << "imput failed" << endl;
		return 1;
	}
	
	// TEST CHECKPOINT --- OK

	list names;
	itemtype reader;

	sourcefile >> reader; //primes while loop.

	while(sourcefile && !names.isfull()) // if there is more data and the array is not full....
	{
		if(!names.isthere(reader) && reader < 200) // sends <reader> to the function isthere() which checks if the data is already there. 
			// if it is, it will return the bool value true, and make the if statement false.
			names.insert(reader);
		// if the data represented by reader does not already exist, it will add it to the database.
		sourcefile >> reader;
	}

	cout << "Number of unique readings: " << names.getlength() << endl;

	cout << "here is the list of data" << endl << endl;

	while(names.hasnext())
	{
		reader = names.getnextitem();
		cout << reader << endl;
	}

	names.deleteitem(1337);
	names.resetlist();// deletes 1337 automatically

	return 0;

}


Also, is there any way to use this program on a grouping of strings rather than integers? I tried to switch the typedef statement to

"typedef string itemtype" but it didn't seem to want to do that.

thanks!
Last edited on
None of the member functions of list is defined, only declared.
a new problem

I managed to fix it and get it to work, but I would like to get this thing to work with strings instead.


My book said all I needed to do was to change

typedef int itemtype

to

1
2
3
using namespace std; 

typedef string itemtype


in the .h file, but that didn't seem to do anything, it doesn't seem to reckognize "string" as a valid data type to assign a typedef to.
Make sure you are including the string header file.
using namespace std;

and

#include <string>

seem to have no effect on the build errors, in fact using namespace std; makes an additional error.
Are you using Visual C++ 6.0?
Topic archived. No new replies allowed.