473,566 Members | 3,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"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<c lass Image>(void)"
(??1?$List@VIma ge@@@@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 13527
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<c lass Image>(void)"
(??1?$List@VIma ge@@@@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
10071
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 symbol _IID_ISampleGrabber applicap.obj : error LNK2001: unresolved external symbol _CLSID_NullRenderer applicap.obj : error LNK2001: unresolved...
0
5366
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 ATL::ChTraitsCRT<char> > > __thiscall CdbLastOLEError::GetDescription(void)" (? GetDescription@CdbLastOLEError@@QAE?AV?$CStringT@DV?...
4
2788
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 the Powrprof.h file and use the Powrprof.lib file in your project, which I did, but when I build, it compiles fine but I get this Link error.. :
0
2333
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 missing ? -- Dani
1
1505
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 ComFortuneTeller.obj : error LNK2001: unresolved external symbol _IID_IFortuneTeller I don't known what's wrong with my code(I refer to the demo code from "COM/DCOM...
2
2235
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)" (??0Init@ios_base@std@@QAE@XZ) referenced in function "void __cdecl std::`dynamic initializer for '_Ios_init''(void)" (??__E_Ios_init@std@@YAXXZ)
8
4879
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 a bunch of "unresolved external symbol _imp_FtpFindFirstFileA@20.......blah blah." errors. Can someone explain why this is happening and how to fix...
7
3099
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: vector_main.obj : error LNK2019: unresolved external symbol "public: __thiscall Vector<int>::~Vector<int>(void)" (??1?$Vector@H@@QAE@XZ)...
2
5825
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 1>c:\users\rafael jr\documents\visual studio 2010\Projects\Inventory CS226\Debug\Inventory CS226.exe : fatal error LNK1120: 1 unresolved externals Can...
0
7683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7586
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7899
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8113
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6270
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5487
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3628
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1204
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.