unresolved Externals

Hello everybody ,
I have been working on this code for 6 hours , and after ending , I encountered the following error which i can't handle , could you help , please !?
here is my code
//QueList.h
#pragma once
#include"NODE.h"
//template<class T>


typedef int ERROR_CODE ;
#define SUCCESS 0
#define OVERFLOW -1
#define UNDERFLOW -2


template<class T>

class QueList
{
public:
QueList();
~QueList();



bool isembtyqueue();
ERROR_CODE append(T Item);
ERROR_CODE serve() ;
ERROR_CODE retrieve(T & x ) ;









protected: int count ;
NODE<T> * front ; //they are pointers to classes from the type NODE
NODE<T> * rear ;
};



//QueList.cpp

#include "QueList.h"

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

//<T>
template<class T>
QueList<T>::QueList()
{

cout<<"default constructor"<<endl;
front = rear = NULL ;
count = 0 ;
}




//////////////////////////////////////////////////////isembty




template<class T>
bool QueList<T>::isembtyqueue(){
return( (front == NULL) || (count == 0 ) ) ;
}
////////////////////////////////////////////////////////////append//////////




template<class T>
ERROR_CODE QueList<T>::append(T Item){

NODE<T> * p ; //creating a node
p = new NODE<T> ;//shall not forget the <T>
p ->item = Item ;
p ->next = NULL ;

if(isembtyqueue()){
front = rear = p ;


}
else{
rear ->next = p ;
rear = p ;
}
count++ ;
return SUCCESS ;
}
/////////////////////////////////////////////////////////////////////////serve\\\





template<class T>
ERROR_CODE QueList<T>::serve(){
ERROR_CODE outcome = SUCCESS ;
NODE<T> * p ;


if(isembtyqueue()){
cout<<"embty queue"<<endl;
outcome = UNDERFLOW ;

}
else{//not embty list ************************** we have a posssibility of a single node ********

p = front ;
/* if(count == 1 ){//a single node
front = front ->next ;
rear = front ;
delete p ;
count-- ;
return outcome ;
*/
//else
front = front -> next ;
delete p ;
count-- ; ///////////////f()///////////////very imporatant ::
///////////////////////////////////**********************
if(front == NULL){
rear = NULL ;
}



}//second else
return outcome ;


//}//first else

}//func



/////////////////////////////////////////////////////////////////retrieve///////////////////////////////


template<class T>
ERROR_CODE QueList<T>::retrieve(T & x){
ERROR_CODE outcome = SUCCESS ;
if(isembtyqueue()){
cout<<"embty queue"<<endl;
outcome = UNDERFLOW ;

}
else{
x = front->item ;

}
return outcome ;
}



//////////////////////////////////////////////////////deatructor



template<class T>
QueList<T>::~QueList()
{
NODE<T> * m ;

while(!isembtyqueue()){
m = front ;
front = front ->next;
delete m;

}
rear = NULL ;
front = NULL ;
cout = 0 ;
}


//NODE.h
#pragma once







template<class T>
class NODE
{
public:
T item ;
NODE<T>* next;
NODE();
NODE(T);

~NODE() ;
};


//NODE.cpp
#include "NODE.h"
#include<iostream>

using namespace std ;








template<class T>
NODE<T>::NODE()
{
item = 0 ;
next = NULL ;
};


template<class T>

NODE<T>::NODE(T y)
{
item = y ;
next = NULL;
}




template<class T>
NODE<T>::~NODE()
{
}
//Extended.h
#pragma once
#include "Quelist.h"



template<class T>
class Extended :
public QueList<T>
{
public:




void clear();
ERROR_CODE serve_and_retrieve(T & Item) ;
// int queuesize();
};


//Extended.cpp
#include "Extended.h"
#include<iostream>
#include"NODE.h"
#include"QueList.h"
using namespace std ;





////////////////////////////////////////////////////////clear
template<class T>
void Extended<T>::clear()
{

NODE<T> * p ;

while(!isembtyqueue()){
p = front ;
front = front ->next ;
delete p ;


}
front = rear = NULL ;
count = 0 ;

}//destructor

///////////////////////////////////////////serve and retieve


template<class T>
ERROR_CODE Extended<T>::serve_and_retrieve(T & Item){
ERROR_CODE outcome = SUCCESS ;
if(isembtyqueue()){
cout<<"embty queue \n";
outcome = UNDERFLOW ;
}
else
{
NODE<T> * p ;
p = front ;
Item = front ->item ;
front = front ->next ;
delete p ;
count-- ;
}
return outcome ;
}

////////////////////////////////////////////////////queuesize

/*
template<class T>
int Extended<T>::queuesize(){
return count ;
}


*/
//main
#include "QueList.h"
#include"NODE.h"
#include<iostream>
#include<conio.h>
#include"Extended.h"
using namespace std ;



int main(){
QueList <int> ANNOS ;
Extended<int> wadee ;
int x = 8 ;
wadee.append(x) ;



//cout<<wadee.queuesize()<<endl;

return 0 ;
}
////I barely used functions in the main , and despite this I have these Errors



1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall QueList<int>::~QueList<int>(void)" (??1?$QueList@H@@QAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: int __thiscall QueList<int>::append(int)" (?append@?$QueList@H@@QAEHH@Z) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall QueList<int>::QueList<int>(void)" (??0?$QueList@H@@QAE@XZ) referenced in function _main
1>C:\Users\M..s\Documents\Visual Studio 2010\Projects\Queuessss\Debug\Queuessss.exe : fatal error LNK1120: 3 unresolved externals
1>
1>Build FAILED
Templates are instantiated at compile time; the compiler needs to see the definitions.

Move all the template definitions from the .cpp files to the corresponding .h files.
(QueList.cpp => QueList.h etc.)
///do you mean to do like this ????

#pragma once







template<class T>
class NODE
{
public:
T item ;
template<class T>
NODE<T>::NODE()
{
item = 0 ;
next = NULL ;
};


template<class T>

NODE<T>::NODE(T y)
{
item = y ;
next = NULL;
}




template<class T>
NODE<T>::~NODE()
{
}
Yes. For the templates, you only have the header files - no .cpp files.
Topic archived. No new replies allowed.