Linker issue.

Hi
i have brobelm while compiling the program.
i`m getting this error:
1>Library.obj : error LNK2019: unresolved external symbol "public: __thiscall StudentNotFound::StudentNotFound(void)" (??0StudentNotFound@@QAE@XZ) referenced in function "public: void __thiscall Library::clearFines(long)" (?clearFines@Library@@QAEXJ@Z)

what is that ?


Library.h:
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
#ifndef _LIBRARY_H_
#define _LIBRARY_H_

#include <iostream>
#include <string>
#include <time.h>
#include <list>
#include <algorithm>
#include "Student.h"
#include "LibraryItem.h"

using namespace std;

class Library {
public:
	//Consturcor
	Library(time_t _today ){
	today = time(NULL);
	}
	void addTitle(LibraryItem* item);
	void addStudent(Student student);
	void borrowTitle(const long id, const long catNum);
	void returnTitle(const long id, const long catNum);
	void endDay(){};
	void clearFines(const long id);
	//Distructor
	~Library();
private:
	time_t today;
	list<Student> students;
	list<LibraryItem*> items;
};
#endif 



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 <iostream>
#include <list>
#include <algorithm>
#include <string>
#include "Library.h"
#include "Student.h"
#include "LibraryItem.h"
#include "exceptions.h"

#define DAY 86400

using namespace std;

//...
void Library::borrowTitle(const long id, const long catNum){
	try{
		long searchId_S = 1;
		long searchId_I = 1;
		list<Student>::iterator stud;
		stud = find_if(students.begin(),students.end(),searchStudent(searchId_S));
		if (stud == students.end())
			throw StudentNotFound();
		list<LibraryItem*>::iterator itm;
		itm = find_if(items.begin(),items.end(),searchItem(searchId_I));
		if (itm == items.end())
			throw ItemNotFound();
		if (!(stud->findInLoanList(catNum)))
			throw AlreadyBorrowedByStudent();
		stud->addToLoanList(*itm);
		(*itm)->setLoaningDate(today);
		(*itm)->setLoanStatus(true);
	}
	catch(ItemNotFound& e){
		cout << e.what() << "(id=" << catNum << ")" << endl;
	}
	catch(StudentNotFound& e){
		cout << e.what() << "(id=" << id << ")" << endl;
	}
	catch(AlreadyBorrowedByStudent& e){
		cout << "student" << id << e.what() << "catalogid" << catNum << endl;
	}
}
//...


exceptions.h:
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
#include <exception>


class DuplicateItemAdding: public exception {
	long index;
public:	
	DuplicateItemAdding(long i): index(i){}
	virtual const char* what() const {
		return "library cannot add item with the same id twice";
	}
	long getIndex() const { 
		return index;
	}
};

class DuplicateStudentAdding: public exception {
	long index;
public:	
	DuplicateStudentAdding(long i): index(i){}
	virtual const char* what() const {
		return "library cannot add title with the same catalogid twice";
	}
	long getIndex() const { 
		return index;
	}
};

class StudentNotFound: public exception {
public:
	StudentNotFound();
	virtual const char* what() const {
		return "Student NOT exists";
	}
};

class ItemNotFound: public exception {
public:
	ItemNotFound();
	virtual const char* what() const {
		return "Item NOT exists";
	}
};

class ItemAlreadyLoaned: public exception {
public:
	ItemAlreadyLoaned();
	virtual const char* what() const {
		return "Item Already Borrowed";
	}
};

class AlreadyBorrowedByStudent: public exception {
public:
	AlreadyBorrowedByStudent();
	virtual const char* what() const {
		return "lready borrowed";
	}
};

class NotBorrowedByStudent: public exception {
public:
	NotBorrowedByStudent();
	virtual const char* what() const {
		return "Item is not borrowed by student";
	}
};



Last edited on
closed account (zb0S216C)
It's because you haven't provided a definition for StudentNotFound's constructor.

Wazzak
Topic archived. No new replies allowed.