undefined reference to

All set till compilation step.
All files are compiled.
I am getting this error while linking this project :(

"LinkedList_main.cpp:(.text+0x13a): undefined reference to `Linked_List<int>::~Linked_List()"

I am also getting this error wwhen I called other functions implemented like insert, display, delete, etc

// File Linked_List.h
template <class Object>

class Linked_List
{
private:

struct Node
{
Object info;
Node *next;

Node() : info(0), next(NULL)
{ }
};

Node *head;
Node *tail;
unsigned long size;

public:

Linked_List(): head(NULL), tail(NULL), size(0)
{ }

Node* create_node();
void free_node(Node *p);
void destroy_list();
~Linked_List();


};

//File Linked_List.cpp

#include <iostream>
#include "Linked_List.h"
using namespace std;

template <class Object>
void Linked_List<Object>::free_node(Node *p)
{
size--;
delete p;
}

template <class Object>
void Linked_List<Object>::destroy_list()
{

Node *temp;
while(head->next != NULL)
{
temp = head->next;
head->next = temp->next;
delete temp;
}

count = 0;

}

template <class Object>
Linked_List<Object>::~Linked_List()
{
destroy_list();
}


}

// File Main.cpp

#include <iostream>
#include "Linked_List.h"
using namespace std;

int main()
{
Linked_List<int> L1;

return 0;
}
Template functions/classes can't go in .cpp files. You must put all function definitions in the header.
Thanks, Problem Solved,
I am using gcc compiler for windows not VC++
so whenever I build this project using command line I get following msg from windows...

LinkedList_main.cpp has stopped working
Windows can check for problem solution online

Why is it so???
sth wrong with pointers???
sth wrong with pointers???
Yes.

This
1
2
3
4
5
6
template <class Object>
void Linked_List<Object>::free_node(Node *p)
{
size--;
delete p;
}
will delete the node but it's still in the list

This
1
2
3
4
5
6
7
8
9
10
11
template <class Object>
void Linked_List<Object>::destroy_list()
{

Node *temp;
while(head->next != NULL)
{
temp = head->next;
head->next = temp->next;
delete temp;
}
deletes all nodes but will crash if 'head' is NULL (no elements in the list)
Topic archived. No new replies allowed.