Getting "Unresolved External Symbol" Error when trying to run the program

Please see the following three codes,

Header 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
#pragma once
#include <iostream>
struct task {
	int id;
	int dur;
	int s_time;
	int e_time;
	int *dep;
	// Adding three extra variables
	int ls; 
	int lf; 
	int *f_deps; 
};

class Schedular {

	task * arr; // array for tasks 
	int *n_d; // dependencies list
	int *n_f; 
	int n; // Total tasks 
public:
	Schedular();
	Schedular(task *ts, int n);
	void setTaskDuration();
	void set_nth_TaskDuration(int i, int t);
	void printTaskDependencyList(int i);
	void completionTime();
	
};


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
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
#include "Schedular.h"
using namespace std;

Schedular::Schedular()
{
	arr = NULL;
}
Schedular::Schedular(task * ts, int n)
{
	system("cls"); 
	ts = new task[n];
	n_f = new int[n]; 
	n_d = new int[n]; // Stores dependencies of all tasks 
	this->n = n; 
	int temp; 
	//Taking Input 
	// First Task has no Predecessor
	cout << "Enter Duration for Task 1: "; 
	cin >> ts[0].dur;
	ts[0].dep = NULL; 
	for (int i = 1; i < n; i++)
	{
		cout << "Enter Duration for Task " << i + 1 << ": ";
		cin >> ts[i].dur; 
		cout << "Enter number of Predecessors for Task " << i + 1 << ": "; 
		cin >> temp;
		ts[i].dep = NULL; // giving default value of NULL. 
		ts[i].dep = new int[temp];
		for (int z = 0; z < temp; z++)
		{
			cout << "Enter Predecessor #" << z + 1 << ": "; 
			cin >> ts[i].dep[z]; 
		}
	}
	// Storing the tasks which one task can call
	for (int task = 0; task < n; task++)
	{
		int count = 0, k = 0; 
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < n_d[i]; j++)
			{
				if (arr[i].dep[j] == task)
					count++; 
			}
		}
		arr[task].f_deps = new int[count]; 
		n_f[task] = count; 
		for (int i = 0; i < n; i++)
		{
			for (int j = 0; j < n_d[i]; j++)
			{
				if (arr[i].dep[j] == task)
					arr[task].f_deps[k++] = task;
			}
		}
	}
}
void Schedular::setTaskDuration()
{
	for (int i = 0; i < n; i++)
	{
		int t;
		cout << "Enter the time duration for task " << i << " :";
		cin >> t;
		arr[i].dur = t;
	}
}

void Schedular::set_nth_TaskDuration(int i, int t)
{
	arr[i].dur = t;
}

void Schedular::printTaskDependencyList(int i)
{
	for (int i = 0; i < n; i++)
	{
		cout << "For Task " << i + 1 << ": ";
		for (int j = 0; j < n_d[i]; j++)
		{
			cout << arr[i].dep[j] << " ";
		}
		cout << endl; 
	}
	for (int i = 0; i < n; i++)
	{
		cout << "For Task " << i + 1 << ": ";
		for (int j = 0; j < n_f[i]; j++)
		{
			cout << arr[i].f_deps[j] << " ";
		}
		cout << endl;
	}
}

void Schedular::completionTime()
{

}


Main

1
2
3
4
5
6
7
8
9
10
11
#include "Schedular.h"
using namespace std;
int main()
{
	task *ptr = NULL; 
	int n = 8;
	Schedular obj(ptr, n); 
	cout << endl;
	system("pause");
	return 0;
}


I am getting this error when I try to run this program,

1
2
1>Source.obj : error LNK2019: unresolved external symbol "public: __thiscall Schedular::~Schedular(void)" (??1Schedular@@QAE@XZ) referenced in function _main
1>E:\Visual Studio\Projects\Project12\Debug\Project12.exe : fatal error LNK1120: 1 unresolved externals



Now, from what I have learned, you get this error if you haven't defined Default Constructor but I have done that clearly... Can anyone help me resolve this issue? Thank you
It doesn't really make sense for the exact code you've posted, but normally that error (complaining about a missing destructor) would be caused by having declared the dtor in the class but never actually defining it. You probably need a dtor for your class since you have dynamically allocated memory to clean up.

If you're programming for C++11 or better you should never use the macro NULL; use the keyword nullptr instead.

BTW, I don't know if it's on purpose or not, but "scheduler" doesn't usually have an 'a' in it.
Topic archived. No new replies allowed.