Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another LNK2001 Error!! 1

Status
Not open for further replies.

Milby7

Programmer
Dec 5, 2003
67
GB
hi!

i'm having problems linking what seems to prodominantly be static constants & variables within a couple of classes in a win32 dll project i'm writing.

it may be worth noting that i've actually implemented all class methods in their header files (no cpp files for classes!!) & also implemented namespaces. neither of which i've ever done before. i'm hoping this is ok!?

here's a few snippets of the code & the output from the (debug) build:


// +++++++++++++
// (EXCEPTION.H)
// +++++++++++++

#include "doctrans.h" // application definitions etc.

namespace Sector
{
namespace DataType
{
//
// exception class
//

class Exception
{
public:

void SetNumber(int iError)
{
m_iErrorCode = iError;
};

int GetNumber()
{
return m_iErrorCode;
};

void Clear()
{
m_iErrorCode = Exception::EXCEPTION_OK;
};

static Exception* Instance()
{
if (Exception::m_pInstance == NULL)
Exception::m_pInstance = new Exception;

return Exception::m_pInstance;
};

static const int EXCEPTION_OK = DTR_OK;

protected:

Exception()
{
// don't allow objects to be created directly
};

private:

static Exception* m_pInstance;

int m_iErrorCode;

};
} // DataType
} // Sector

// ++++++++++++++
// (IDATASTORE.H)
// ++++++++++++++

#include <string>

using namespace std;

namespace Sector
{
namespace Data
{
/*
****************************
idatastore interface
****************************
*/

interface IDataStore
{
public:

virtual string* ReadRecord(long lRecNo) = 0;
virtual long WriteRecord(long lRecNo, string* psWriteBuff) = 0;
virtual long CreateRecord(long lPos) = 0;
virtual long DeleteRecord(long lRecNo) = 0;
virtual long GetCurrentRecord() = 0;

virtual string* ReadField(long lRecNo, string sFieldName) = 0;
virtual long WriteField(long lRecNo, string sFieldName, string* psWriteBuff) = 0;

virtual bool Read(string sQuery = "") = 0;
virtual bool Create() = 0;
virtual bool Delete() = 0;
virtual bool Refresh() = 0;
virtual bool Flush(long min = 0, long max = -1) = 0;
virtual bool Clear() = 0;
virtual long GetOccurenceCount() = 0;

virtual string GetName();
virtual void SetName(string sName);
virtual string GetInfo();
virtual bool SetInfo(string sXMLDesc);

};
} // Data
} // Sector

// ++++++++++++++
// (TEXTPARSER.H)
// ++++++++++++++

#include <string>
#include "doctrans.h" // application definitions etc.
#include "linkedlist.h"
#include "queue.h"
#include "repository.h"
#include "exception.h"

namespace Sector
{
namespace Library
{
namespace DocumentTransformer
{
namespace Text
{
// declare used namespaces...

using namespace Sector::DataType;

/*
************************
textparser class
************************
*/

class TextParser : public IParser
{
public:

//
// constructor
//

TextParser(Repository* pRepository,
bool bProcessPrivateText)
{
m_pRepository = pRepository;
m_bProcessPrivate = bProcessPrivateText;
m_pAppException = Exception::Instance();

// initialise fake constants...
// (not really constants because not integral types)
TextParser::InitConstants();
};

//
// public iparser operations
//

virtual bool Parse(Converter* pConverter)
{
// a load of code...
};

//
// public constants
//

private:

//
// private static methods
//

static void InitConstants()
{
// necessary because it's not possible to have non-integral
// type constants initialised in a class definition...
if (TextParser::CTRL_CODE_END != "98")
{
TextParser::CTRL_CODE_EXTEND_LENGTH = "71";
TextParser::CTRL_CODE_HIGHLIGHT = "91";
TextParser::CTRL_CODE_UNDERLINE = "92";
TextParser::CTRL_CODE_PARAGRAPH_START = "95";
TextParser::CTRL_CODE_PARAGRAPH_END = "94";
TextParser::CTRL_CODE_PRE_MASK_CLAUSE = "97";
TextParser::CTRL_CODE_PRE_DICT_CLAUSE = "99";
TextParser::CTRL_CODE_END = "98";
TextParser::CTRL_CODE_PRIVATE_TEXT1 = "990";
TextParser::CTRL_CODE_PRIVATE_TEXT2 = "991";
TextParser::CTRL_CODE_PRIVATE_TEXT3 = "992";
TextParser::CTRL_CODE_PAGE_BREAK1 = "980";
TextParser::CTRL_CODE_PAGE_BREAK2 = "981";
TextParser::CTRL_CODE_PAGE_BREAK3 = "982";
}
};

//
// private methods
//

TextParser()
{
// don't allow objects to be created without parameters passed
};

__inline bool IsPrivateTextCode(string sDictCode)
{
// some code...
};

//
// private static member data
//

// (i wanted these to be constants but they're not integral types
// so not allowed!?!?)

static string CTRL_CODE_EXTEND_LENGTH;
static string CTRL_CODE_HIGHLIGHT;
static string CTRL_CODE_UNDERLINE;
static string CTRL_CODE_PARAGRAPH_START;
static string CTRL_CODE_PARAGRAPH_END;
static string CTRL_CODE_PRE_MASK_CLAUSE;
static string CTRL_CODE_PRE_DICT_CLAUSE;
static string CTRL_CODE_END;
static string CTRL_CODE_PRIVATE_TEXT1;
static string CTRL_CODE_PRIVATE_TEXT2;
static string CTRL_CODE_PRIVATE_TEXT3;
static string CTRL_CODE_PAGE_BREAK1;
static string CTRL_CODE_PAGE_BREAK2;
static string CTRL_CODE_PAGE_BREAK3;

//
// private member data
//

Repository* m_pRepository;
bool m_bProcessPrivate;
Exception* m_pAppException;

};
} // Text
} // DocumentTransformer
} // Library
} // Sector

// ++++++++++++++
// (DICTPARSER.H)
// ++++++++++++++

#include <string>
#include "doctrans.h" // application definitions etc.
#include "iparser.h"
#include "textparser.h"
#include "linkedlist.h"
#include "queue.h"
#include "repository.h"
#include "converter.h"
#include "exception.h"

namespace Sector
{
namespace Library
{
namespace DocumentTransformer
{
namespace Text
{
// declare used namespaces...

using namespace Sector::DataType;
using namespace Sector::Data;

/*
************************
dictparser class
************************
*/

class DictParser : public IParser
{
public:

//
// constructor
//

DictParser(Repository* pRepository)
{
m_pRepository = pRepository;
m_pAppException = Exception::Instance();

// initialise fake constants...
// (not really constants because not integral types)
DictParser::InitConstants();
};

//
// public iparser operations
//

virtual bool Parse(Converter* pConverter)
{
// a load of code...
};

//
// public constants
//

static const int FIELD_JUSTIFY_LEFT = 76; // ascii 'L'
static const int FIELD_JUSTIFY_RIGHT = 82; // ascii 'R'

private:

//
// private static methods
//

static void InitConstants()
{
// necessary because it's not possible to have non-integral
// type constants initialised in a class definition...
if (DictParser::CTRL_CODE_END != "98")
{
DictParser::CTRL_CODE_END = "98";
DictParser::CTRL_CODE_PRIVATE_TEXT1 = "990";
DictParser::CTRL_CODE_PRIVATE_TEXT2 = "991";
DictParser::CTRL_CODE_PRIVATE_TEXT3 = "992";
DictParser::CTRL_CODE_PAGE_BREAK1 = "980";
DictParser::CTRL_CODE_PAGE_BREAK2 = "981";
DictParser::CTRL_CODE_PAGE_BREAK3 = "982";
DictParser::CTRL_CODE_HIGHLIGHT = "91";
DictParser::CTRL_CODE_UNDERLINE = "92";
DictParser::pREMASK_SIGNIFIER = "~~";
}
};
//
// private methods
//

DictParser()
{
// don't allow objects to be created without parameters passed
};

__inline bool IsPreMaskRecord(string* psText)
{
if (psText->find(DictParser::pREMASK_SIGNIFIER) == -1)
return false;

return true;
};

__inline bool IsPrivateTextCode(string sDictCode)
{
// some code...
};

__inline bool IsPageBreak(string sDictCode)
{
// some code...
};

//
// private static member data
//

// (same as class above. wanted these to be constants)

static string CTRL_CODE_END;
static string CTRL_CODE_PRIVATE_TEXT1;
static string CTRL_CODE_PRIVATE_TEXT2;
static string CTRL_CODE_PRIVATE_TEXT3;
static string CTRL_CODE_PAGE_BREAK1;
static string CTRL_CODE_PAGE_BREAK2;
static string CTRL_CODE_PAGE_BREAK3;
static string CTRL_CODE_HIGHLIGHT;
static string CTRL_CODE_UNDERLINE;
static string PREMASK_SIGNIFIER;

//
// private member data
//

Repository* m_pRepository;
Exception* m_pAppException;

};
} // Text
} // DocumentTransformer
} // Library
} // Sector

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

------ Build started: Project: doctrans, Configuration: Debug Win32 ------

Compiling...
main.cpp
-+- COMPILING filepath...\stdinc.h
-+- COMPILING filepath...\resource.h
-+- COMPILING filepath...\doctrans.h
-+- COMPILING filepath...\linkedlist.h
-+- COMPILING filepath...\queue.h
-+- COMPILING filepath...\exception.h
-+- COMPILING filepath...\guiapplication.h
-+- COMPILING filepath...\iapplication.h
-+- COMPILING filepath...\uniface.h
-+- COMPILING filepath...\idatastore.h
-+- COMPILING filepath...\idocumenttransformer.h
-+- COMPILING filepath...\repository.h
-+- COMPILING filepath...\textitem.h
-+- COMPILING filepath...\converter.h
-+- COMPILING filepath...\iparser.h
-+- COMPILING filepath...\textconverter.h
-+- COMPILING filepath...\textparser.h
-+- COMPILING filepath...\dictconverter.h
-+- COMPILING filepath...\dictparser.h
-+- COMPILING filepath...\texttransformer.h
-+- COMPILING i:\program\user\richard millen\sectornet\projects\text processor\doctrans - utext\31-10-2004\doctrans\main.cpp
Linking...
Creating library Debug/doctrans.lib and object Debug/doctrans.exp
main.obj : error LNK2001: unresolved external symbol "private: static class Sector::DataType::Exception * Sector::DataType::Exception::m_pInstance" (?m_pInstance@Exception@DataType@Sector@@0PAV123@A)

main.obj : error LNK2001: unresolved external symbol "public: virtual bool __thiscall Sector::Data::IDataStore::SetInfo(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?SetInfo@IDataStore@Data@Sector@@UAE_NV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

main.obj : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Sector::Data::IDataStore::GetInfo(void)" (?GetInfo@IDataStore@Data@Sector@@UAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)

main.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall Sector::Data::IDataStore::SetName(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?SetName@IDataStore@Data@Sector@@UAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)

main.obj : error LNK2001: unresolved external symbol "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Sector::Data::IDataStore::GetName(void)" (?GetName@IDataStore@Data@Sector@@UAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::TextParser::CTRL_CODE_EXTEND_LENGTH" (?CTRL_CODE_EXTEND_LENGTH@TextParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::TextParser::CTRL_CODE_PRE_MASK_CLAUSE" (?CTRL_CODE_PRE_MASK_CLAUSE@TextParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::TextParser::CTRL_CODE_END" (?CTRL_CODE_END@TextParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::TextParser::CTRL_CODE_PRE_DICT_CLAUSE" (?CTRL_CODE_PRE_DICT_CLAUSE@TextParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::TextParser::CTRL_CODE_PARAGRAPH_END" (?CTRL_CODE_PARAGRAPH_END@TextParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::TextParser::CTRL_CODE_PARAGRAPH_START" (?CTRL_CODE_PARAGRAPH_START@TextParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::TextParser::CTRL_CODE_UNDERLINE" (?CTRL_CODE_UNDERLINE@TextParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::TextParser::CTRL_CODE_HIGHLIGHT" (?CTRL_CODE_HIGHLIGHT@TextParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::TextParser::CTRL_CODE_PAGE_BREAK3" (?CTRL_CODE_PAGE_BREAK3@TextParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::TextParser::CTRL_CODE_PAGE_BREAK2" (?CTRL_CODE_PAGE_BREAK2@TextParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::TextParser::CTRL_CODE_PAGE_BREAK1" (?CTRL_CODE_PAGE_BREAK1@TextParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::TextParser::CTRL_CODE_PRIVATE_TEXT3" (?CTRL_CODE_PRIVATE_TEXT3@TextParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::TextParser::CTRL_CODE_PRIVATE_TEXT2" (?CTRL_CODE_PRIVATE_TEXT2@TextParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::TextParser::CTRL_CODE_PRIVATE_TEXT1" (?CTRL_CODE_PRIVATE_TEXT1@TextParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::DictParser::CTRL_CODE_UNDERLINE" (?CTRL_CODE_UNDERLINE@DictParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::DictParser::CTRL_CODE_HIGHLIGHT" (?CTRL_CODE_HIGHLIGHT@DictParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::DictParser::CTRL_CODE_END" (?CTRL_CODE_END@DictParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::DictParser::pREMASK_SIGNIFIER" (?PREMASK_SIGNIFIER@DictParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::DictParser::CTRL_CODE_PAGE_BREAK3" (?CTRL_CODE_PAGE_BREAK3@DictParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::DictParser::CTRL_CODE_PAGE_BREAK2" (?CTRL_CODE_PAGE_BREAK2@DictParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::DictParser::CTRL_CODE_PAGE_BREAK1" (?CTRL_CODE_PAGE_BREAK1@DictParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::DictParser::CTRL_CODE_PRIVATE_TEXT3" (?CTRL_CODE_PRIVATE_TEXT3@DictParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::DictParser::CTRL_CODE_PRIVATE_TEXT2" (?CTRL_CODE_PRIVATE_TEXT2@DictParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

main.obj : error LNK2001: unresolved external symbol "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Sector::Library::DocumentTransformer::Text::DictParser::CTRL_CODE_PRIVATE_TEXT1" (?CTRL_CODE_PRIVATE_TEXT1@DictParser@Text@DocumentTransformer@Library@Sector@@0V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)

Debug/doctrans.dll : fatal error LNK1120: 29 unresolved externals

Build log was saved at "file://i:\Program\User\Richard Millen\Sectornet\Projects\Text Processor\Doctrans - utext\31-10-2004\Doctrans\Debug\BuildLog.htm"
doctrans - 30 error(s), 1 warning(s)


---------------------- Done ----------------------

Build: 0 succeeded, 1 failed, 0 skipped

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

i've looked all over the place for similar problems but can't find them!!

does anyone think they might know what this is??
 
This is an excellent sample of the principle that only .h files are not adequate tool to implement classes in many cases. You must initialize all your static class members in your program in a .cpp file(s), for example:
Code:
// classes.h file (declarations):
class AnyClass
{
...
static string stat;
...
};
...
// classes.cpp file (definitions):
#include "classes.h"
string AnyClass::stat = "Static member initialization";
...
There is one and only one definition of the static member in your program code. You can't do it with .h files only...
 
thanks dude! that makes a lot of sense!!
 
hi!!

i've moved all implementation code into seperate source files, have waded through a load more LNK2001 & LNK2019 errors, but am really stuck!! i'm still getting the errors above on a linked list class i've written. i've included the code & output below. any help would be REALLY appreciated!! thanks!!

// ++++++++++++
// LINKEDLIST.H
// ++++++++++++

// declare classes...

template <class type> class ListElement;
template <class type> class LinkedList;

/*
************************
linkedlist class
************************
*/

template <class type> class LinkedList
{
public:

//
// constructor/destructor
//

LinkedList<type>();
~LinkedList<type>();

//
// public methods
//

bool InsertNext(ListElement<type>* pElement, const type* pData);
bool RemoveNext(ListElement<type>* pElement, type** ppData);

ListElement<type>* GetHead();
ListElement<type>* GetTail();

int GetSize();

bool IsHead(const ListElement<type>& element);
bool IsTail(const ListElement<type>& element);
bool IsEmpty();

ListElement<type>* GetElementByIndex(int index);

LinkedList<type>* Clone();
LinkedList<type>* Copy();

void FreeData();

private:

//
// private methods
//

void SetHead(ListElement<type>* pHead);
void SetTail(ListElement<type>* pTail);
void SetSize(int size);

//
// private member data
//

int m_size;
ListElement<type>* m_pHead;
ListElement<type>* m_pTail;

};

/*
*************************
listelement class
*************************
*/

template <class type> class ListElement
{
public:

//
// constructor/destructor
//

ListElement();
~ListElement();

//
// public methods
//

type* GetData();
void SetData(type* pData);

void FreeData();

ListElement<type>* GetNext();
void SetNext(ListElement<type>* pNext);

type* CloneData();

private:

//
// private member data
//

type* m_pData;
ListElement<type>* m_pNext;

};

// ++++++++++++++
// LINKEDLIST.CPP
// ++++++++++++++

#include <stdlib.h>
#include "linkedlist.h"

/*
************************
linkedlist class
************************
*/

template <class type>
LinkedList<type>::LinkedList() : m_size(0), m_pHead(NULL), m_pTail(NULL)
{
// do nothing
}

template <class type>
LinkedList<type>::~LinkedList()
{
if (m_pHead != NULL)
delete m_pHead;
}

template <class type>
bool LinkedList<type>::InsertNext(ListElement<type>* pElement, const type* pData)
{
ListElement<type>* pNewElement = new ListElement<type>;

if (pNewElement == NULL)
return false;

pNewElement->SetData(const_cast<type*> (pData));

if (pElement == NULL) // insertion @ head of list...
{
if (this->GetSize() == 0)
this->SetTail(pNewElement);

pNewElement->SetNext(this->GetHead());
this->SetHead(pNewElement);
}
else // insertion somewhere other than @ the head...
{
if (pElement->GetNext() == NULL)
this->SetTail(pNewElement);

pNewElement->SetNext(pElement->GetNext());
pElement->SetNext(pNewElement);
}

this->SetSize(this->GetSize() + 1);

return true;
}

template <class type>
bool LinkedList<type>::RemoveNext(ListElement<type>* pElement, type** ppData)
{
ListElement<type>* pOldElement;

if (this->GetSize() == 0)
return false;

// if null then handle removal from head of list...
if (pElement == NULL)
{
*ppData = this->GetHead()->GetData();
pOldElement = this->GetHead();
this->SetHead(this->GetHead()->GetNext());

if (this->GetSize() == 1)
{
this->SetTail(NULL);
}
}
else
{
if (pElement->GetNext() == NULL)
return false;

*ppData = pElement->GetNext()->GetData();
pOldElement = pElement->GetNext();
pElement->SetNext(pElement->GetNext()->GetNext());

if (pElement->GetNext() == NULL)
{
this->SetTail(pElement);
}
}

delete pOldElement;

this->SetSize(this->GetSize() - 1);

return true;
}

template <class type>
ListElement<type>* LinkedList<type>::GetHead()
{
return m_pHead;
}

template <class type>
ListElement<type>* LinkedList<type>::GetTail()
{
return m_pTail;
}

template <class type>
int LinkedList<type>::GetSize()
{
return m_size;
}

template <class type>
bool LinkedList<type>::IsHead(const ListElement<type>& element)
{
return this->GetHead() == element ? true : false;
}

template <class type>
bool LinkedList<type>::IsTail(const ListElement<type>& element)
{
return this->GetTail() == element ? true : false;
}

template <class type>
bool LinkedList<type>::IsEmpty()
{
return this->GetSize() == 0 ? true : false;
}

template <class type>
ListElement<type>* LinkedList<type>::GetElementByIndex(int index)
{
int i;
ListElement<type>* pTmp = NULL;

if (this->GetSize() == 0 || index >= this->GetSize())
return pTmp;

pTmp = this->GetHead(); // element zero

for (i = 1; i <= index; i++)
{
pTmp = pTmp->GetNext();
}

return pTmp;
}

template <class type>
LinkedList<type>* LinkedList<type>::Clone()
{
LinkedList<type>* pNewList = NULL;
ListElement<type>* pSrcElement = NULL;

if (this->GetSize() == 0)
return pNewList;

pNewList = new LinkedList<type>;
pSrcElement = this->GetHead();

pNewList->InsertNext(NULL, pSrcElement->CloneData());

while (pSrcElement->GetNext() != NULL)
{
pSrcElement = pSrcElement->GetNext();

pNewList->InsertNext(pNewList->GetTail(), pSrcElement->CloneData());
}

return pNewList;
}

template <class type>
LinkedList<type>* LinkedList<type>::Copy()
{
LinkedList<type>* pNewList = NULL;
ListElement<type>* pSrcElement = NULL;

if (this->GetSize() == 0)
return pNewList;

pNewList = this;
pSrcElement = this->GetHead();

pNewList->InsertNext(NULL, pSrcElement->CloneData());

while (pSrcElement->GetNext() != NULL)
{
pSrcElement = pSrcElement->GetNext();

pNewList->InsertNext(pNewList->GetTail(), pSrcElement->GetData());
}

return pNewList;
}

template <class type>
void LinkedList<type>::FreeData() // only call when data is allocated on the heap
{
ListElement<type>* pElement = NULL;

if (this->GetSize() == 0)
return;

pElement = this->GetHead();
pElement->FreeData();

while (pElement->GetNext() != NULL)
{
pElement = pElement->GetNext();
pElement->FreeData();
}
}

template <class type>
void LinkedList<type>::SetHead(ListElement<type>* pHead)
{
m_pHead = pHead;
}

template <class type>
void LinkedList<type>::SetTail(ListElement<type>* pTail)
{
m_pTail = pTail;
}

template <class type>
void LinkedList<type>::SetSize(int size)
{
m_size = size;
}

/*
*************************
listelement class
*************************
*/

template <class type>
ListElement<type>::ListElement<type>() : m_pData(NULL), m_pNext(NULL)
{
// do nothing
}

template <class type>
ListElement<type>::~ListElement<type>()
{
if (m_pNext != NULL)
delete m_pNext;
}

template <class type>
type* ListElement<type>::GetData()
{
return m_pData;
}

template <class type>
void ListElement<type>::SetData(type* pData)
{
m_pData = pData;
}

template <class type>
void ListElement<type>::FreeData()
{
if (m_pData != NULL)
delete m_pData;
}

template <class type>
ListElement<type>* ListElement<type>::GetNext()
{
return m_pNext;
}

template <class type>
void ListElement<type>::SetNext(ListElement<type>* pNext)
{
m_pNext = pNext;
}

template <class type>
type* ListElement<type>::CloneData()
{
type* pNewData = new type;

*pNewData = *m_pData;

return pNewData;
}

++++++++++++++++++++++++++++++++++++++++

Linking...
Creating library Debug/doctrans.lib and object Debug/doctrans.exp

dictconverter.obj : error LNK2019: unresolved external symbol "public: class ListElement<struct _FORMATDESCRIPTOR> * __thiscall ListElement<struct _FORMATDESCRIPTOR>::GetNext(void)" (?GetNext@?$ListElement@U_FORMATDESCRIPTOR@@@@QAEPAV1@XZ) referenced in function "public: virtual bool __thiscall DictConverter::AddFormatDescriptor(struct _FORMATDESCRIPTOR *)" (?AddFormatDescriptor@DictConverter@@UAE_NPAU_FORMATDESCRIPTOR@@@Z)

textconverter.obj : error LNK2001: unresolved external symbol "public: class ListElement<struct _FORMATDESCRIPTOR> * __thiscall ListElement<struct _FORMATDESCRIPTOR>::GetNext(void)" (?GetNext@?$ListElement@U_FORMATDESCRIPTOR@@@@QAEPAV1@XZ)

dictconverter.obj : error LNK2019: unresolved external symbol "public: struct _FORMATDESCRIPTOR * __thiscall ListElement<struct _FORMATDESCRIPTOR>::GetData(void)" (?GetData@?$ListElement@U_FORMATDESCRIPTOR@@@@QAEPAU_FORMATDESCRIPTOR@@XZ) referenced in function "public: virtual bool __thiscall DictConverter::AddFormatDescriptor(struct _FORMATDESCRIPTOR *)" (?AddFormatDescriptor@DictConverter@@UAE_NPAU_FORMATDESCRIPTOR@@@Z)

textconverter.obj : error LNK2001: unresolved external symbol "public: struct _FORMATDESCRIPTOR * __thiscall ListElement<struct _FORMATDESCRIPTOR>::GetData(void)" (?GetData@?$ListElement@U_FORMATDESCRIPTOR@@@@QAEPAU_FORMATDESCRIPTOR@@XZ)

dictconverter.obj : error LNK2019: unresolved external symbol "public: class ListElement<struct _FORMATDESCRIPTOR> * __thiscall LinkedList<struct _FORMATDESCRIPTOR>::GetHead(void)" (?GetHead@?$LinkedList@U_FORMATDESCRIPTOR@@@@QAEPAV?$ListElement@U_FORMATDESCRIPTOR@@@@XZ) referenced in function "public: virtual bool __thiscall DictConverter::AddFormatDescriptor(struct _FORMATDESCRIPTOR *)" (?AddFormatDescriptor@DictConverter@@UAE_NPAU_FORMATDESCRIPTOR@@@Z)

textconverter.obj : error LNK2001: unresolved external symbol "public: class ListElement<struct _FORMATDESCRIPTOR> * __thiscall LinkedList<struct _FORMATDESCRIPTOR>::GetHead(void)" (?GetHead@?$LinkedList@U_FORMATDESCRIPTOR@@@@QAEPAV?$ListElement@U_FORMATDESCRIPTOR@@@@XZ)

dictconverter.obj : error LNK2019: unresolved external symbol "public: bool __thiscall LinkedList<struct _FORMATDESCRIPTOR>::InsertNext(class ListElement<struct _FORMATDESCRIPTOR> *,struct _FORMATDESCRIPTOR const *)" (?InsertNext@?$LinkedList@U_FORMATDESCRIPTOR@@@@QAE_NPAV?$ListElement@U_FORMATDESCRIPTOR@@@@PBU_FORMATDESCRIPTOR@@@Z) referenced in function "public: virtual bool __thiscall DictConverter::AddFormatDescriptor(struct _FORMATDESCRIPTOR *)" (?AddFormatDescriptor@DictConverter@@UAE_NPAU_FORMATDESCRIPTOR@@@Z)

textconverter.obj : error LNK2001: unresolved external symbol "public: bool __thiscall LinkedList<struct _FORMATDESCRIPTOR>::InsertNext(class ListElement<struct _FORMATDESCRIPTOR> *,struct _FORMATDESCRIPTOR const *)" (?InsertNext@?$LinkedList@U_FORMATDESCRIPTOR@@@@QAE_NPAV?$ListElement@U_FORMATDESCRIPTOR@@@@PBU_FORMATDESCRIPTOR@@@Z)

dictconverter.obj : error LNK2019: unresolved external symbol "public: __thiscall LinkedList<struct _FORMATDESCRIPTOR>::LinkedList<struct _FORMATDESCRIPTOR>(void)" (??0?$LinkedList@U_FORMATDESCRIPTOR@@@@QAE@XZ) referenced in function "public: virtual bool __thiscall DictConverter::AddFormatDescriptor(struct _FORMATDESCRIPTOR *)" (?AddFormatDescriptor@DictConverter@@UAE_NPAU_FORMATDESCRIPTOR@@@Z)

textconverter.obj : error LNK2001: unresolved external symbol "public: __thiscall LinkedList<struct _FORMATDESCRIPTOR>::LinkedList<struct _FORMATDESCRIPTOR>(void)" (??0?$LinkedList@U_FORMATDESCRIPTOR@@@@QAE@XZ)

dictconverter.obj : error LNK2019: unresolved external symbol "public: void __thiscall LinkedList<struct _FORMATDESCRIPTOR>::FreeData(void)" (?FreeData@?$LinkedList@U_FORMATDESCRIPTOR@@@@QAEXXZ) referenced in function "public: virtual void __thiscall DictConverter::ClearFormatDescriptors(void)" (?ClearFormatDescriptors@DictConverter@@UAEXXZ)

textconverter.obj : error LNK2001: unresolved external symbol "public: void __thiscall LinkedList<struct _FORMATDESCRIPTOR>::FreeData(void)" (?FreeData@?$LinkedList@U_FORMATDESCRIPTOR@@@@QAEXXZ)

converter.obj : error LNK2001: unresolved external symbol "public: void __thiscall LinkedList<struct _FORMATDESCRIPTOR>::FreeData(void)" (?FreeData@?$LinkedList@U_FORMATDESCRIPTOR@@@@QAEXXZ)

dictconverter.obj : error LNK2019: unresolved external symbol "public: __thiscall LinkedList<struct _FORMATDESCRIPTOR>::~LinkedList<struct _FORMATDESCRIPTOR>(void)" (??1?$LinkedList@U_FORMATDESCRIPTOR@@@@QAE@XZ) referenced in function "public: void * __thiscall LinkedList<struct _FORMATDESCRIPTOR>::`scalar deleting destructor'(unsigned int)" (??_G?$LinkedList@U_FORMATDESCRIPTOR@@@@QAEPAXI@Z)

textconverter.obj : error LNK2001: unresolved external symbol "public: __thiscall LinkedList<struct _FORMATDESCRIPTOR>::~LinkedList<struct _FORMATDESCRIPTOR>(void)" (??1?$LinkedList@U_FORMATDESCRIPTOR@@@@QAE@XZ)

converter.obj : error LNK2001: unresolved external symbol "public: __thiscall LinkedList<struct _FORMATDESCRIPTOR>::~LinkedList<struct _FORMATDESCRIPTOR>(void)" (??1?$LinkedList@U_FORMATDESCRIPTOR@@@@QAE@XZ)

dictconverter.obj : error LNK2019: unresolved external symbol "public: bool __thiscall LinkedList<struct _FORMATDESCRIPTOR>::RemoveNext(class ListElement<struct _FORMATDESCRIPTOR> *,struct _FORMATDESCRIPTOR * *)" (?RemoveNext@?$LinkedList@U_FORMATDESCRIPTOR@@@@QAE_NPAV?$ListElement@U_FORMATDESCRIPTOR@@@@PAPAU_FORMATDESCRIPTOR@@@Z) referenced in function "protected: virtual void __thiscall DictConverter::OptimiseFormatDescriptors(void)" (?OptimiseFormatDescriptors@DictConverter@@MAEXXZ)

textconverter.obj : error LNK2019: unresolved external symbol "public: bool __thiscall LinkedList<struct _FORMATDESCRIPTOR>::RemoveNext(class ListElement<struct _FORMATDESCRIPTOR> *,struct _FORMATDESCRIPTOR * *)" (?RemoveNext@?$LinkedList@U_FORMATDESCRIPTOR@@@@QAE_NPAV?$ListElement@U_FORMATDESCRIPTOR@@@@PAPAU_FORMATDESCRIPTOR@@@Z) referenced in function "private: int __thiscall TextConverter::GetFormatCode(int)" (?GetFormatCode@TextConverter@@AAEHH@Z)

dictparser.obj : error LNK2019: unresolved external symbol "public: bool __thiscall LinkedList<class TextItem>::InsertNext(class ListElement<class TextItem> *,class TextItem const *)" (?InsertNext@?$LinkedList@VTextItem@@@@QAE_NPAV?$ListElement@VTextItem@@@@PBVTextItem@@@Z) referenced in function "public: virtual bool __thiscall DictParser::parse(class Converter *)" (?Parse@DictParser@@UAE_NPAVConverter@@@Z)

dictparser.obj : error LNK2019: unresolved external symbol "public: class ListElement<class TextItem> * __thiscall LinkedList<class TextItem>::GetTail(void)" (?GetTail@?$LinkedList@VTextItem@@@@QAEPAV?$ListElement@VTextItem@@@@XZ) referenced in function "public: virtual bool __thiscall DictParser::parse(class Converter *)" (?Parse@DictParser@@UAE_NPAVConverter@@@Z)

repository.obj : error LNK2019: unresolved external symbol "public: __thiscall LinkedList<class TextItem>::LinkedList<class TextItem>(void)" (??0?$LinkedList@VTextItem@@@@QAE@XZ) referenced in function "public: __thiscall Repository::Repository(class TextTransformer *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * (__stdcall TextTransformer::*)(void),class TextItem * (__stdcall TextTransformer::*)(void),int (__stdcall TextTransformer::*)(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >))" (??0Repository@@QAE@PAVTextTransformer@@P81@AGPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZP81@AGPAVTextItem@@XZP81@AGHV23@@Z@Z)

repository.obj : error LNK2019: unresolved external symbol "public: __thiscall LinkedList<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::LinkedList<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(void)" (??0?$LinkedList@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAE@XZ) referenced in function "public: __thiscall Queue<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::Queue<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(void)" (??0?$Queue@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAE@XZ)

repository.obj : error LNK2019: unresolved external symbol "public: void __thiscall LinkedList<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::FreeData(void)" (?FreeData@?$LinkedList@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAEXXZ) referenced in function "public: __thiscall Repository::~Repository(void)" (??1Repository@@QAE@XZ)

repository.obj : error LNK2019: unresolved external symbol "public: void __thiscall LinkedList<class TextItem>::FreeData(void)" (?FreeData@?$LinkedList@VTextItem@@@@QAEXXZ) referenced in function "public: __thiscall Repository::~Repository(void)" (??1Repository@@QAE@XZ)

repository.obj : error LNK2019: unresolved external symbol "public: __thiscall LinkedList<class TextItem>::~LinkedList<class TextItem>(void)" (??1?$LinkedList@VTextItem@@@@QAE@XZ) referenced in function "public: void * __thiscall LinkedList<class TextItem>::`scalar deleting destructor'(unsigned int)" (??_G?$LinkedList@VTextItem@@@@QAEPAXI@Z)

repository.obj : error LNK2019: unresolved external symbol "public: __thiscall LinkedList<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::~LinkedList<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(void)" (??1?$LinkedList@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAE@XZ) referenced in function "public: __thiscall Queue<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::~Queue<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(void)" (??1?$Queue@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAE@XZ)

repository.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __thiscall Queue<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::peek(void)" (?Peek@?$Queue@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAEPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ) referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __thiscall Repository::peekInsertRecord(void)" (?PeekInsertRecord@Repository@@UAEPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)

repository.obj : error LNK2019: unresolved external symbol "public: int __thiscall LinkedList<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::GetSize(void)" (?GetSize@?$LinkedList@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAEHXZ) referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __thiscall Repository::peekInsertRecord(void)" (?PeekInsertRecord@Repository@@UAEPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)

repository.obj : error LNK2019: unresolved external symbol "public: bool __thiscall Queue<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::Dequeue(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * *)" (?Dequeue@?$Queue@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAE_NPAPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * __thiscall Repository::GetNextInsertRecord(void)" (?GetNextInsertRecord@Repository@@UAEPAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)

repository.obj : error LNK2019: unresolved external symbol "public: class TextItem * __thiscall Queue<class TextItem>::peek(void)" (?Peek@?$Queue@VTextItem@@@@QAEPAVTextItem@@XZ) referenced in function "public: virtual class TextItem * __thiscall Repository::peekTemplateRecord(void)" (?PeekTemplateRecord@Repository@@UAEPAVTextItem@@XZ)

repository.obj : error LNK2019: unresolved external symbol "public: int __thiscall LinkedList<class TextItem>::GetSize(void)" (?GetSize@?$LinkedList@VTextItem@@@@QAEHXZ) referenced in function "public: virtual class TextItem * __thiscall Repository::peekTemplateRecord(void)" (?PeekTemplateRecord@Repository@@UAEPAVTextItem@@XZ)

repository.obj : error LNK2019: unresolved external symbol "public: bool __thiscall Queue<class TextItem>::Dequeue(class TextItem * *)" (?Dequeue@?$Queue@VTextItem@@@@QAE_NPAPAVTextItem@@@Z) referenced in function "public: virtual class TextItem * __thiscall Repository::GetNextTemplateRecord(void)" (?GetNextTemplateRecord@Repository@@UAEPAVTextItem@@XZ)

repository.obj : error LNK2019: unresolved external symbol "public: bool __thiscall Queue<class TextItem>::Enqueue(class TextItem const *)" (?Enqueue@?$Queue@VTextItem@@@@QAE_NPBVTextItem@@@Z) referenced in function "public: virtual class TextItem * __thiscall Repository::EnqueueInsert(class TextItem *)" (?EnqueueInsert@Repository@@UAEPAVTextItem@@PAV2@@Z)

repository.obj : error LNK2019: unresolved external symbol "public: bool __thiscall Queue<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::Enqueue(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const *)" (?Enqueue@?$Queue@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAE_NPBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: virtual class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall Repository::EnqueueSectionId(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?EnqueueSectionId@Repository@@UAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V23@@Z)

texttransformer.obj : error LNK2019: unresolved external symbol "public: class ListElement<class TextItem> * __thiscall ListElement<class TextItem>::GetNext(void)" (?GetNext@?$ListElement@VTextItem@@@@QAEPAV1@XZ) referenced in function "public: virtual bool __thiscall TextTransformer::print(void)" (?Print@TextTransformer@@UAE_NXZ)

texttransformer.obj : error LNK2019: unresolved external symbol "public: class TextItem * __thiscall ListElement<class TextItem>::GetData(void)" (?GetData@?$ListElement@VTextItem@@@@QAEPAVTextItem@@XZ) referenced in function "public: virtual bool __thiscall TextTransformer::print(void)" (?Print@TextTransformer@@UAE_NXZ)

texttransformer.obj : error LNK2019: unresolved external symbol "public: class ListElement<class TextItem> * __thiscall LinkedList<class TextItem>::GetHead(void)" (?GetHead@?$LinkedList@VTextItem@@@@QAEPAV?$ListElement@VTextItem@@@@XZ) referenced in function "public: virtual bool __thiscall TextTransformer::print(void)" (?Print@TextTransformer@@UAE_NXZ)

Debug/doctrans.dll : fatal error LNK1120: 27 unresolved externals

Build log was saved at "file:filepath\BuildLog.htm"
doctrans - 38 error(s), 0 warning(s)


---------------------- Done ----------------------

Build: 0 succeeded, 1 failed, 0 skipped


 
hello again!

i've still had absolutely no joy, so if anyone can give the slightest bit of help, i'd REALLY appreciate it as don't know how to get round the problem. thanks again!
 
the first lin kerror you have LNK2019

is pointing to an function/vatiable?

" ListElement"

and it cannot find the ListElement properties I'm assuming? Make sure you have included all the required headers etc...

 
listelement is a class defined in linkedlist.h. i did the following in linkedlist.h:

1) declared classes because linkedlist will have references to listelement class within it...

template <class type> class ListElement;
template <class type> class LinkedList;

2) defined linkedlist class
3) defined listelement class

i then just implemented the methods etc for those classes in linkedlist.cpp (with the necessary #include "linkedlist.h" in there)

elsewhere in my project i inherited from the linkedlist class in another class called queue, which should be why there are linker errors involving that class.

wherever the linkedlist etc classes are used there is #include in there. i can't see any differences in the spelling between class definitions/implementations either, so i have no idea what's going on!
 
i've written a tiny little test app to see if i could just get a template class to work. it doesn't work!! i got all the same linker errors. i've copied all the code below, plus the build output, so if anyone realises what i'm doing wrong then i'd really appreciate ANY help you can give. thanks!!

Code:
// test.h

#ifndef _TEST_H_
#define _TEST_H_

template <class type> class Test
{
public:
	
	void SetMember(type Val);
	type GetMember();
	
	Test<type>& Copy();
	
private:
	
	type m_Member;
	
};

#endif // _TEST_H_

Code:
// test.cpp

#include "test.h"

template <class type>
void Test<type>::SetMember(type Val)
{
	this->m_Member = Val;
}

template <class type>
type Test<type>::GetMember()
{
	return this->m_Member;
}

template <class type>
Test<type>& Test<type>::Copy()
{
	return *this;
}

Code:
// main.cpp

#include <iostream>
#include "test.h"

using namespace std;

int main()
{
	Test<int> tst;
	
	cout << "TEMPLATE TEST PROGRAM..." << endl << endl;
	
	tst.SetMember(68);
	
	cout << "TEST CLASS RETURNS\t" << tst.GetMember() << endl;
	
	Test<int> tst2 = tst.Copy();
	
	cout << "TEST CLASS 2 RETURNS\t" << tst2.GetMember() << endl;
	
	cout << "Press any key to end..." << endl;
	
	cin.get();
}

 
sorry!! i forgot the build output!!

Code:
------ Build started: Project: template_test, Configuration: Debug Win32 ------

Compiling...
test.cpp
Linking...

main.obj : error LNK2019: unresolved external symbol "public: class Test<int> & __thiscall Test<int>::Copy(void)" (?Copy@?$Test@H@@QAEAAV1@XZ) referenced in function _main

main.obj : error LNK2019: unresolved external symbol "public: int __thiscall Test<int>::GetMember(void)" (?GetMember@?$Test@H@@QAEHXZ) referenced in function _main

main.obj : error LNK2019: unresolved external symbol "public: void __thiscall Test<int>::SetMember(int)" (?SetMember@?$Test@H@@QAEXH@Z) referenced in function _main

Debug/template_test.exe : fatal error LNK1120: 3 unresolved externals

thanks!!
 
Templates should have all the implementation in the header file (or so I'm told), because of the way that the template specializations are created by the compiler. You usually won't get a compile error if you separate the template interface from the implementation, but when you run it, it won't work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top