Ñ
Ñ©ÔÆÓ¥
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;
}
......
}
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;
}
......
}