   error C4430...
  I got "error C4430: missing type specifier - int assumed. Note: C++ does not support default-int" when I compiled this:#include <iostream>using namespace std;template<class T>class Array{T *pArray;int number;public:explicit Array(int numOfElements);T& operator[](int index) {return pArray[index];}void printAll();};template <class T>Array<T>::Array(int numOfElements){number = numOfElements;pArray = new T[number];}template <class T>Array<T>::printAll(){for(int i = 0; i < number; i++)cout << *pArray << "\n";}int main(){return 0;}This has something to do with defining int or something right? But how do you do that? Or if it isn't that, how do you fix the code up?Thanks in advance!   
  You missed the return type off the printAll functiontemplate <class T>void Array<T>::printAll(){...}Another problem is that you are not freeing the memory that you allocated in the constructor.  You need a delete [] pArray somewhere.You also seem to be reinventing the wheel slightly, the C++ standard library has a dynamic array class template called std::vector.   ;  Whoops! I can't believe I missed that!I know, I'm reinventing the wheel, but I wanted to learn templates.Thanks.   ;template <class T>class DArray{public:DArray();void Set(int offset , T  toset);T Get(int offset);int GetSize();private:T * Arr;int CurSize;int calls;};template <class T>DArray<T> :: DArray(){}template <class T>void DArray<T>::Set(int offset , T  toset){if (calls != 1) {Arr = new T  [1];CurSize = 0;}calls = 1;if (offset > CurSize){T * temp = new T  [offset+1];int x;for (x=0;x<CurSize+1;x++){temp[x] = Arr[x];}delete [] Arr;Arr = new T  [offset+1];for (x=0;x<CurSize+1;x++){Arr[x] = temp[x]; }delete [] temp;Arr[offset] = toset;CurSize = offset;return;}Arr[offset] = toset;}template <class T>T  DArray<T>::Get(int offset){if (offset <= CurSize){if (offset == CurSize+1) return Arr[offset-1];return Arr[offset];}}template <class T>int DArray<T>::GetSize(){if (calls != 1) {return 0;}else{return CurSize + 1;}}this is like the vector class only open source use it if you want   ;Quote:Original post by Black Ace *** Bad Source Snippet Removed ***this is like the vector class only open source use it if you wantSorry, but that code is terrible.  First of all, compilers usually ship the source for std::vector as a header file since it is a template class, so std::vector is already usually "open source" (although there may be restrictions on what you do with the source).  Secondly your DArray class is incredibly inefficient.  Thirdly your DArray class's behaviour is completely undefined.  It's a wonderful example of why people should use the C++ Standard Library instead of writing their own.Enigma   