473,698 Members | 2,097 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 13533
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
10076
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 external symbol
0
5374
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? $StrTraitMFC@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@XZ) referenced
4
2793
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
2345
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
1514
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 Primer plus").
2
2248
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
4891
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 it? Thank you.
7
3104
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) referenced in function _main
2
5833
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 anyone please tell me where my error is or what i'm doing wrong? here is my code:
0
8603
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9027
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7725
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3046
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

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.