I need a template Function to resize an Array of any type.
Here is my try:
class CCommon
{
template < typename T >
static void ResizeArray(T* paArray, int iOldSize, int iNewSize, T tInitValue);
}
..
template < typename T >
void CCommon::ResizeArray(T* paArray, int iOldSize, int iNewSize, T tInitValue)
{
T* paTmpArray = new T[iOldSize];
for(int i = 0; i < iOldSize; i++)
{
paTmpArray[i] = paArray[i];
}
delete [] paArray;
paArray=new T[iNewSize];
for(int i=0; i < iNewSize; i++)
{
paArray[i] = tInitValue;
}
for(int i = 0; i < iOldSize; i++)
{
paArray[i] = paTmpArray[i];
}
delete [] paTmpArray;
}
The CCommon File is even compilable, but if i want to use it i get the Error:
Fehler 2 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ("unresolved external references".)
""public: static void __cdecl CCommon::ResizeArray(int *,int,int,int)" (??$ResizeArray@H@CCommon@@SAXPAHHHH@Z)" in Funktion ""public: void __thiscall CWaebi_OBJ::ReInit(void)" (?ReInit@CWaebi_OBJ@@QAEXXZ)". CWaebi_OBJ.obj
Fehler 3 fatal error LNK1120: 1 nicht aufgelöste externe
This is how i want to call it:
#include CCommon
SomeFunction
{
..
CCommon::ResizeArray<BOOL>( mTextIndexMask, m_iNumberOfLastTextMaskArray, mTextCount, FALSE );
..
}
What is wrong?
regards camelord