   Templates Generating LNK2019???
  I trying to create a Texture Manager (a singleton factory) class for my game engine. The problem is that i wanted to have the TextureMgr to also be a linked list for every texture that loads. The problem is that it keeps saying that i have linking problem when trying to use any of the linked list class. If you wouldn''t mind helping me out cause maybe im not seeing anything but i just cant see the problem.LINKED LIST HEADER CODE// list// by Ryan Sullivan#include "global.h"template class list;#ifndef _NODE_#define _NODE_template class node{T* data;node* next;node* prev;bool isHead;public:node(T* object): data(object),next(0),prev(0),isHead(false){}void setHead(bool bHead);bool getHead();node* getPrev(){ return &next }node* getNext(){ return &prev }T* getData(){ return &data }};#endif _NODE_#ifndef _LIST_#define _LIST_template class list{node* current;public:list() : current(0) { }~list(){ delete current; }bool isHead();bool isTail();void toHead();// goes through all nodes to startvoid toTail();// goes through all nodes to endvoid addObject(E* object);void cutObject(E* object);};#endif _LIST_  LINKED LIST SOURCE CODE#include "list.h"template void node::setHead(bool bHead){isHead = bHead;}template bool node::getHead(){return isHead;}template bool list::isHead(){if(current == NULL)return false;elsereturn true;}template bool list::isTail(){if(current->getNext() == NULL)return true;elsereturn false;}template void list::toHead(){while(current->getPrev() != NULL){current = current->getPrev();}}template void list::toTail(){while(current->getNext() != NULL){current = current->getNext();}}template void list::addObject(E* object){node* newNode = new node(object);if(!hasHead())current = newNode;else{current->getNext() = newNode;current->getPrev() = current;current = current->getNext();}}template void list::cutObject(E* object){node* cutNode = new node(object);if(!hasHead())return(0);else{toHead();while(current != cutNode){current = current->getNext();}current->getPrev() = current->getNext()->getPrev();current = current->getNext();}}  TEXTURE MANAGER HEADERclass TextureMgr : public   list, public Singleton{GLuint allTextures[MAX_TEXTURES];public:TextureMgr(){ }~TextureMgr(){ }texture*addTexture(LPSTR filename);voidcutTexture(texture* argTexture);};  TEXTURE MANAGER SOURCEtexture* TextureMgr::addTexture(LPSTR filename){texture* tTemp;tTemp = new tga(filename);// checks if a texture already loaded has same id numberaddObject(tTemp);this->isHead();return tTemp;}void TextureMgr::cutTexture(texture* argTexture){cutObject(argTexture);} 
quote:Original post by Lurking  I trying to create a Texture Manager (a singleton factory) class for my game engine. The problem is that i wanted to have the TextureMgr to also be a linked list for every texture that loads. The problem is that it keeps saying that i have linking problem when trying to use any of the linked list class. If you wouldn''t mind helping me out cause maybe im not seeing anything but i just cant see the problem.try using ''source'' tags instead of ''code'' tags, as they shorten the hugeness of posts like above. Seeing the full link error message (instead of just the code LNK2019) would probably help. ;  What are you compiliing with?I know in vc6 and possibly in vc7 without a certain keyword I am forgetting that you cannot have template functions in a cpp they must be in the header after the class declaration ;  Edit your original post so the angle brackets show up (they can get interpreted as HTML format codes). ;  Are you also including your template implementation file?  Without "export", the compiler cannot find the implementation of your template class'' member functions unless you also include your implementation function:i.e. in TEXTURE MANAGER SOURCE#include "list.h"#include "list.cpp";  You cannot separate templates into header and source files. The definition and declaration must be in the same file.   Qui fut tout, et qui ne fut rienInvader''s Realm;quote:Original post by Invader X  You cannot separate templates into header and source files. The definition and declaration must be in the same file.   Qui fut tout, et qui ne fut rienInvader''s Realm Sorry but you can do this:temp.h: #if !defined(__TEMP_H)#define __TEMP_Htemplate< typename T >class temp {  void func(const T& t);};#endiftemp.cpp: #include "temp.h"template<typename T>void temp<T>::func(const T& t) {  std::cout << t << endl;}Regards,Jeff ;  In what compiler?   Qui fut tout, et qui ne fut rienInvader''s Realm;  In any compiler, that is valid C++.You will get linker errors, from the other cpps which have the declaration (in the .h) but not the definition (in the .cpp), unless you explicitly instantiate versions of the function in the .cpp;  GCC v 2.95.3MS VC++ 6Dev-C++ Version 4.9.8.0 (whichever gcc is in there)Which compiler are you using where this doesn''t work?Remember, as I said above you MUST include the cpp file as well.Regards,Jeff 