473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

"LNK2019 - Unresolved external Symbol" while using templates

So here is my Code:

template <class T>
struct Nodes
{
T *Data; // The Image
char Name[50]; // The Name of the image

Nodes<T> *Prev;
Nodes<T> *Next;
};
typedef struct Nodes Node;
template <class T>
class List
{
Node *Current;

public:

List();
~List();

};

---------------------------------------------------

#include "List.h"

template <class T>
List<T>::List()
{

}

template <class T>
List<T>::~List()
{

}

================================================== ==

error LNK2019: unresolved external symbol "public: __thiscall
List<class Image>::~List<class Image>(void)"
(??1?$List@VImage@@@@QAE@XZ) referenced in function main...

Thats the error I get. Is this one of those subtle c++ bugs that I need
to work around? my main is quite simple, all it does is instanciate the
class. thats all:

List<int> foo;

Im completely confused.

Sep 30 '05 #1
4 13512
Mastadex wrote:
So here is my Code:

template <class T>
struct Nodes
{
T *Data; // The Image
char Name[50]; // The Name of the image

Nodes<T> *Prev;
Nodes<T> *Next;
There's no need for the <T> here. Nodes is fine.
};
typedef struct Nodes Node;
This is unnecessary in C++. You can drop this line and not change any
other code.


template <class T>
class List
{
Node *Current;

public:

List();
~List();

};

---------------------------------------------------

#include "List.h"

template <class T>
List<T>::List()
{

}

template <class T>
List<T>::~List()
{

}

================================================== ==

error LNK2019: unresolved external symbol "public: __thiscall
List<class Image>::~List<class Image>(void)"
(??1?$List@VImage@@@@QAE@XZ) referenced in function main...

Thats the error I get. Is this one of those subtle c++ bugs that I need
to work around? my main is quite simple, all it does is instanciate the
class. thats all:

List<int> foo;

Im completely confused.


You need to put the template function definitions in the header file.
See this FAQ:

http://www.parashift.com/c++-faq-lit....html#faq-35.7

Also, unless you're doing homework here, I'd suggest using std::list
instead of reinventing the wheel.

Cheers! --M

Sep 30 '05 #2
mlimber's got it exactly.
You need to put all templates in the header file.
There should be no .cpp file for templated classes.

Sep 30 '05 #3
John Fullman wrote:
mlimber's got it exactly.


Got what exactly?

Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Sep 30 '05 #4
thanks guys.

im still a bit rusty with C++ after my vacation :/

Sep 30 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Rodolphe | last post by:
Hello, I'm French so sorry for my approximate English. When I try to compile a project under Visual C++ 6.0, I've got the following errors : applicap.obj : error LNK2001: unresolved external...
0
by: Cris | last post by:
Hi I´m converting a VC6 Project to VC7 and I´m having the follow problem: error LNK2019: unresolved external symbol "public: class ATL::CStringT<char,class StrTraitMFC<char,class ...
4
by: naveenadevi | last post by:
Hi, I'm trying to use some power management features with windowsx xp and I have visual studio .net 2003 installed. As per documentation of ACPI, you can use the power options by including...
0
by: danip | last post by:
Hi, I converted a VC++ 6.0 dll to VC++ 2003. It's unmanaged. Now when I'm trying to implement calling to static method that returns CString I receive the error message above in the Link. What I'm...
1
by: Awin | last post by:
Hello all, I'm a beginner of COM programming, I have a exercise, but got a compile error with ComFortuneTeller.obj : error LNK2001: unresolved external symbol _IID_IQuotation...
2
by: Pardeep Kadian | last post by:
Hi , having as issue , which gives errors like this while linking... error LNK2019: unresolved external symbol "public: __thiscall std::ios_base::Init::Init(void)"...
8
by: amievil | last post by:
Hello. I'm devloping MFC program and found something weird happening. When I compile it with "debug mode", it compile fine, and runs fine. however, when I compile with "release mode", I get...
7
by: JustBeSimple | last post by:
Hi Everyone, I'm having a problem compiling useing the VS2005 .NET I need help to resolve those error, I try to create a new project it doesn't help any suggestion? I got the following errors:...
2
by: Rafael Douglas | last post by:
Hello All, I was writing a program and ran across this error: error LNK2019: unresolved external symbol "double __cdecl setTotalCost(void)" (?setTotalCost@@YANXZ) referenced in function _main...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.