#ifndef __CUSTUTIL_MYVECTORH
#define __CUSTUTIL_MYVECTORH
////////////////////////////////////////////////////////////////
template < class T >
class MyVector{
public:
//constructors destructors
MyVector(void);
~MyVector(void);
...
//operators
T& operator[](int nPosition);
...
};
////////////////////////////////////////////////////////////////
#endif //defined __CUSTUTIL_MYVECTORH
MyVector.cpp
#include "MyVector.h"
#ifndef NULL
#define NULL 0
#endif
////////////////////////////////////////////////////////////////
template < class T >
MyVector::MyVector(void)
: listSize(0), ptrList(NULL)
{
//no extra inits
}
////////////////////////////////////////////////////////////////
template < class T >
MyVector::~MyVector(void){
if(list) delete [] list;
}
////////////////////////////////////////////////////////////////
template < class T >
T& MyVector::MyVector[](int nPosition)
{
//incomplete
if(nPosition >= listSize) return NULL;
else if(nPosition < 0) return NULL;
else return list[nPosition];
}
_________________:: MajorShredd ::
The glass is neither half full nor half empty;
rather, it is a combination of both, and the system is perfect.