473,382 Members | 1,302 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,382 software developers and data experts.

Help for me:LNK2019

Hi,I have met a trouble,has anyone can help me?

error detail:
Linking...
ListTest.obj : error LNK2019: unresolved external symbol "public: __thiscall
com::LinearList<int>::LinearList<int>(int)" (??0?$LinearList@H@com@@QAE@H@Z)
referenced in function _main
D:\Project\CPPTest\Debug\CPPTest.exe : fatal error LNK1120: 1 unresolved
externals

<ListTest.cpp>
-------------------------------------------------------------------------------------------
#include <stdafx.h>
#include "List.h"
#include <iostream>

using namespace std;
using namespace com;

void main()
{
try
{
LinearList<int> L(10);
//cout << "Length = " << L.Length() << endl;
//cout << "IsEmpty = " << L.IsEmpty() <<endl;
////L.Insert( 0 , 2 ).Insert( 1 ,6 ) ;
////cout << "List is " << L << endl;
//cout << "IsEmpty = " << L.IsEmpty() << endl;
//int z = 0;
////L.Find( 1 , z ) ;
//cout << "First element is " << z << endl;
//cout << "Length = " << L.Length() << endl;
////L.Delete( 1 , z ) ;
//cout << "Deleted element is " << z << endl;
////cout << "List is " << L << endl;

}
catch (...)
{
cerr << "An exception has occurred" << endl;
}
}
<List.h>
-------------------------------------------------------------------------------------------
#include "stdafx.h"
#include <iostream>
using namespace std;

namespace com {
// ÄÚ´æ²»×ã
class NoMem {
public:
NoMem () {}
};

template<class T> class LinearList {
public:
//¹¹Ô캯Êý
LinearList(int MaxListSize);
//Îö¹¹º¯Êý
~LinearList() {delete [] element;}
bool IsEmpty() const {return length == 0;}
int Length() const {return length;}
//·µ»ØµÚk¸öÔªËØÖÁxÖÐ
bool Find(int k, T& x) const;
// ·µ»ØxËùÔÚλÖÃ
int Search(const T& x) const;
// ɾ³ýµÚk¸öÔªËز¢½«Ëü·µ»ØÖÁxÖÐ
LinearList<T>& Delete(int k, T& x);
// ÔÚµÚk¸öÔªËØÖ®ºó²åÈëx
LinearList<T>& Insert(int k, const T& x);
void Output(ostream& out) const;
private:
int length;
int MaxSize;
// һά¶¯Ì¬Êý×é
T *element;
} ;

};

<List.cpp>
-----------------------------------------------------------------------------
#include <stdafx.h>
#include "List.h"
#include <iostream>
using namespace std;

namespace com {

// ʹn e wÒý·¢N o M e mÒì³£¶ø²»ÊÇx a l l o cÒì³£
void my_new_handler()
{
throw NoMem();
}

//set new handler for new operation
new_handler Old_Handler_=set_new_handler(my_new_handler);

template<class T> LinearList<T>::LinearList(int MaxListSize)
{
// »ùÓÚ¹«Ê½µÄÏßÐÔ±íµÄ¹¹Ô캯Êý
MaxSize = MaxListSize;
element = new T[MaxSize];
length = 0;
}
......
}
Mar 3 '06 #1
2 1615

"Ñ©ÔÆÓ¥" <xu********@hotmail.com> wrote in message
news:Ob**************@TK2MSFTNGP15.phx.gbl...
Hi,I have met a trouble,has anyone can help me?

error detail:
Linking...
ListTest.obj : error LNK2019: unresolved external symbol "public:
__thiscall com::LinearList<int>::LinearList<int>(int)"
(??0?$LinearList@H@com@@QAE@H@Z) referenced in function _main
D:\Project\CPPTest\Debug\CPPTest.exe : fatal error LNK1120: 1 unresolved
externals

<ListTest.cpp>
-------------------------------------------------------------------------------------------
#include <stdafx.h>
#include "List.h"
#include <iostream>

using namespace std;
using namespace com;

void main()
{
try
{
LinearList<int> L(10);
//cout << "Length = " << L.Length() << endl;
//cout << "IsEmpty = " << L.IsEmpty() <<endl;
////L.Insert( 0 , 2 ).Insert( 1 ,6 ) ;
////cout << "List is " << L << endl;
//cout << "IsEmpty = " << L.IsEmpty() << endl;
//int z = 0;
////L.Find( 1 , z ) ;
//cout << "First element is " << z << endl;
//cout << "Length = " << L.Length() << endl;
////L.Delete( 1 , z ) ;
//cout << "Deleted element is " << z << endl;
////cout << "List is " << L << endl;

}
catch (...)
{
cerr << "An exception has occurred" << endl;
}
}
<List.h>
-------------------------------------------------------------------------------------------
template<class T> class LinearList {
public:
//¹¹Ô캯Êý
LinearList(int MaxListSize);
//Îö¹¹º¯Êý
~LinearList() {delete [] element;}
<snip>
} ;

};

<List.cpp>
-----------------------------------------------------------------------------
#include <stdafx.h>
#include "List.h"
#include <iostream>
using namespace std;

namespace com {

// ʹn e wÒý·¢N o M e mÒì³£¶ø²»ÊÇx a l l o cÒì³£
void my_new_handler()
{
throw NoMem();
}

//set new handler for new operation
new_handler Old_Handler_=set_new_handler(my_new_handler);

template<class T> LinearList<T>::LinearList(int MaxListSize)
{
// »ùÓÚ¹«Ê½µÄÏßÐÔ±íµÄ¹¹Ô캯Êý
MaxSize = MaxListSize;
element = new T[MaxSize];
length = 0;
}


I am pretty sure it will work if you do not split declaration and
implementation into 2 separate files.
i.e. you have to put the full implementation in the header file.

if you want to split the declaration and implementation of a template class
you would have to use the export keyword.

quote from stroustroub, programming C++ language 3d edition, page 351:
"To be accessible from other compilation units, a template definition must
be explicitly declared export ...
otherwise, the definition must be in scope whenever the template is used"

sadly, the export keyword is not supported in VC, so you have to put the
implementation in your header file.

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"
Mar 3 '06 #2
Ñ©ÔÆÓ¥ wrote:
Hi,I have met a trouble,has anyone can help me?

template<class T> class LinearList {
public:
//¹¹Ô캯Êý
LinearList(int MaxListSize);
...
} ;


Where's definition of this constructor?
Mar 3 '06 #3

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

Similar topics

1
by: Vishal Saxena | last post by:
Hi, I am new to this news group, hope to get prompt solution from you, gurus of VC. Well i had a project developed in VC++ 6.0, it uses Adobe Plugin Development SDK, I am trying to upgrade my...
1
by: Hadi | last post by:
Hi, I have two files libqdbm.dll.a and qdbm.dll. In cygwin libqdbm.dll.a is located in /usr/local/lib while qdbm.dll is located in windows/system32. I have my test project which I compiled in...
0
by: drumdawg21 | last post by:
Ive been working on this problem for a long time now and really need some help. I have a program in c++ code that gives me build errors and my program is having problems. I have two source files in...
2
by: allen zhang | last post by:
When I upgrade my old vc6 application to VS.NET2003, I always get a linker error, I had fixed some compiling error, the error message, error LNK2019: MultiWME error LNK2019: ÎÞ·¨½âÎöµÄÍⲿ·ûºÅ...
2
by: hazizpour | last post by:
Hello I hope I am in the correct newsgroup, if not please let me know. I am trying to build a sample for using a certain library ( IFC mapping to C++ classes, see www.cstb.fr) with MS Visual...
2
by: rangalo | last post by:
Hi All, I have succeeded in compiling a massive project, originally from vc6 to VS .Net 2005. Now, while linking I am having loads of linker errors with the above code. LNK20019 and LNK2001....
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
1
by: girays | last post by:
I have a template class which name is EntityRepository and when I compile this class I get no error. But when I use this class in a main method I get LNK2019 linking error. std::map object is used...
1
by: eraserwars | last post by:
I have been googeling every possible solution, but I cannot seem to fix LNK2019. My code is below, but I just cannot understand how anything related to LNK2019 from Microsoft's help center applies...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.