Header file:
Code: Select all
#ifndef __ARRAY_H__
#define __ARRAY_H__
typedef unsigned short USHORT;
const USHORT DefaultSize = 10;
template <class T>
class saArray
{
public:
saArray(USHORT size = DefaultSize);
saArray(const saArray &rhs);
~saArray(){delete [] pType;}
saArray& operator=(const saArray&);
T& operator[](USHORT offset);
const T& operator[](USHORT offset) const {return pType[offset];}
USHORT GetSize(){return Size;}
private:
T *pType;
USHORT Size;
};
#endif
Code: Select all
template <class T>
saArray<T>::saArray(USHORT size):
Size(size)
{
pType = new T[size];
for(USHORT i = 0; i<size; i++)
pType[i] = 0;
}
Code: Select all
"saArray<unsigned short>::saArray(unsigned short)", referenced from:
_main in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
My first solution is to include the Array.cpp instead of .h .
The other solution is to move the function implementation to the header file.
Thanks in advance
Sanshin
Edit:
This actually applies to all of the functions.