#pragma once
#include <iostream>
/*
 * Author: Makhdoom Shah 4872
 * Date of creation:22/2-2008
 * Date of revision:
 * Revesion #: 1
 */



using namespace std;

//typedef double itemType; // need for another type, change it here

template<class T>
class dynarray
{
public:
	dynarray( int s = 0 ); // default size is 0
	
	dynarray( const dynarray &rhs );
	
	const dynarray &operator=( const dynarray & rhs);
	
	~dynarray();

	void push_back( itemType item );
	void push_front( T item );
	void add(T item);
	int getCap();
	bool isEmpty() const;
	
	bool pop_back( );
	
	void insert( itemType item, int pos );
	
	T erase( int pos );
	
	void clear( );
	
	int size( ) const;
	
	bool empty( ) const;
	
	itemType &at( int pos ) const;
	
	
	// overloaded operators	
	T &operator[]( int pos ); // non const variant
	
	const T &operator[]( int pos ) const; // const variant
	
	dynarray operator+( const dynarray &rhs );
	
	dynarray &operator+=( const dynarray &rhs );
	
	bool operator==( const dynarray &rhs );
	
	bool operator!=( const dynarray &rhs );
	
	friend ostream &operator<<( ostream &str, const dynarray &rhs );
	
private:
	// private functions
	void expand( ); // expand the array
	
	T *dynarray; // pointer to the first element of the array
	
	int cap; // capacity of the array
	
	int arraySize; // size of the array
};


template<class T>
dynarray<T>::dynarray(int s)
{
    if(s>=0)
	{
		dynarray = new T[s];

		for(int i=0; i <s; i++)			
		{
			//theArray[i] = 0;		
		}
		cap = s;
		arraySize = 0;
    }
    else{
         cerr << "Please enter a valid size: dynArray("<<s<<")"<<endl;    }
}

//Copy constructor
template<class T>
dynarray<T>::dynarray(const dynarray &rhs)
{
	cout<< "Copy Costrustor is called now";
    cap = rhs.getCap();
	arraySize = rhs.getSize();
    dynarray = new T[cap];	
    for(int i=0; i <rhs.getSize(); i++)			
	{
		dynarray[i] = rhs[i];		
	}	
}

//Copy assignment operator
template<class T>
const dynarray<T> &dynarray<T>::operator=(const dynarray & rhs)
{
	if (this == &rhs)
		return *this;
		
    delete[] dynarray;                         // delete old array
    dynarray = new T[rhs.getCap()];     // create new array with the rhs capacity
    cap = rhs.getCap();              // copy the capacity and the size 
    arraySize = rhs.getSize();                 
    	
    for(int i=0; i <rhs.getSize(); i++)			
    {
    	dynarray[i] = rhs[i];		// copy all elements
    }
    	
    return *this;
}

//deconstructor
template<class T>
dynarray<T>::~dynarray()
{
	delete[] dynarray;            
}
// Insert new item at first possition in array
template<class T>
void dynarray<T>::push_front(T item)
{
	// increase the size of array
     arraySize++;                             
     
     // move all elements one possition
     for(int i=arraySize;i>1;i--)
     dynarray[i-1] = dynarray[i-2];  
             
     // add new elemets to first pos
     dynarray[0] = item;     
}

template<class T>
void dynarray<T>::push_back(T item)
{
       add(item);
}

template<class T>
bool dynarray<T>::pop_back( )
{
	T temp =0;
	if(arraySize>0)
	{
		arraySize--;
        //temp = theArray[arraySize];         
		//theArray[arraySize]=0;
		return 1;
	}
        //return temp;
	return 0;
                       
}
// add new item to last possition in array
template<class T>
void dynarray<T>::add(T item)
{
     // expand if needed
     if(arraySize>=cap)
             expand();
               
     dynarray[arraySize] = item;
     arraySize++; 
     empty = false;    
}

// insert an item anywhere in the array
template<class T>
void  dynarray<T>::insert(T item, int pos)
{
     // return if possition is invalid
     if(pos>arraySize)
        return;
      
      // move all elements to make room for new item
     arraySize++;
     for(int i=arraySize;i>pos;i--)
        dynarray[i-1] = dynarray[i-2];
     
     // insert new item     
     dynarray[pos] = item;
     empty = false;
}	
// delete one possition in array
template<class T>
T dynarray<T>::erase(int pos)
{
     // returns if possition is invalid
     if(pos>=arraySize)
     {    
          cerr << "Index out of bounds: erase("<<pos<<")"<<endl;
		  return;
     }   
     
     T temp = dynarray[pos];
     arraySize--;
     
     //move all elements
     for(int i=pos;i<arraySize;i++)
         dynarray[i] = dynarray[i+1];     
     return temp;    
}

// delete all elements in the array
template<class T>
void dynarray<T>::clear()
{
	//T *temp = new T[cap];
	//delete theArray;
	arraySize=0;
//	return *this;  
}
// get capacity of array
template<class T>
int dynarray<T>::getCap() const
{
    return cap;
    
}
// get size of array
template<class T>
int  dynarray<T>::getSize() const
{
    return arraySize;
    
}

// return if array is empty or not
template<class T>
bool  dynarray<T>::isEmpty() const
{
    if(arraySize==0)
		return true;        
    
    return false;
}
// change size of array, only if array is empty
template<class T>
void dynarray<T>::reSize(int s)
{    
    if(s>arraySize)
    {
         cap = s;
         cout << cap << endl;                   
    }
    else
    {
        cerr << "Index out of bounds: reSize("<<s<<")"<<endl;
        }	
}

// print all elements in the array
template<class T>
void dynarray<T>::printArray()
{	cout<<"[";
	for(int i=0; i<arraySize; i++)
	{ 
		cout<<dynarray[i];	
        if(i!=arraySize-1)
            cout<<",";	
	}
	cout << "]" << endl;
}

template<class T>
T &dynarray<T>::operator[]( int pos )
{  
      return dynarray[pos];
}

// const variant
template<class T>
const T &dynarray<T>::operator[]( int pos ) const
{
      double temp = dynarray[pos];
      return temp;      
}

// add two arrays together, can cascade
template<class T>
dynarray<T> &dynarray<T>:: operator+( const Array &rhs )
{
    // create a temp array to hold the adds
    dynarray temp;
    
    // put first array in temp
    for(int k=0;k<this->arraySize;k++)
        temp.add(this->dynarray[k]);
      
    // put second array in temp
    for(int i=0;i<rhs.getSize();i++)
        temp.add(rhs[i]);
    
    // return temp array
    return temp;     
}
// test if array is equal to another array or not equal
template<class T>
bool dynarray<T>::operator!=( const dynarray<T> &rhs )
{
     // run test only if the size of both arrays are equal
     if(!(*this == rhs))
     {    
          return true;
     }

     return false;
}
template <class T>
void dynarray<T>::ascendSort()
{
int i, j;
T temp;
for(i = 0; i < this->arSize; i++)
{
for(j = i + 1; j < this->arSize; j++)
{
if (this->anArray[i] > this->anArray[j])
{
temp = this->anArray[i];
this->anArray[i] = this->anArray[j];
this->anArray[j] = temp;
}
}
}
for (int f = 0;f<this->arSize;f++)
{
cout<<anArray[f];
}
}

template <class T>
void dynarray<T>::descendSort()
{
int i, j;
T temp;
for(i = 0; i < this->arSize; i++)
{
for(j = i + 1; j < this->arSize; j++)
{
if (this->anArray[i] < this->anArray[j])
{
temp = this->anArray[i];
this->anArray[i] = this->anArray[j];
this->anArray[j] = temp;
}
}
}

for (int f = 0;f<this->arSize;f++)
{
cout<<anArray[f];
}
}
void main()
{
dynarray<T> ary;
ary.insert(2.0,0);
ary.insert(2.0,1);
ary.insert(2.0,2);
ary.insert(3.0,3);
////?*?*?*??*?*?*?*??*?*?*?*?*?*?*?*??**??*?*?*?*??*?*?*?*?*?*?*?*??**
//Testing of Insert method
///?*?*?*??*?*?*?*?*?*??*?*??*?*?*??*?*?*?*?*?*?*??*?*?*?*?*?*?*?*??**
cout<<"This is Insert Method Test Start"<<endl;
cout<<ary<<endl;
cout<<"This is Insert Method Test End"<<endl;
ary.push_back(7.0);
ary.push_back(8.0);
cout<<"This is Push_back Method Test Start"<<endl;
cout<<ary<<endl;
cout<<endl;
//////?*?*?*??*?*?*?*??*?*?*?*?*?*?*?*??**??*?*?*?*??*?*?*?*?*?*?*?*??**
////Testing of Push_back method
/////?*?*?*??*?*?*?*?*?*??*?*??*?*?*??*?*?*?*?*?*?*??*?*?*?*?*?*?*?*??**
cout<<"This is Push_back Method Test End"<<endl;
cout<<"This is erase Method Test Start"<<endl;
ary.erase(3);
//////?*?*?*??*?*?*?*??*?*?*?*?*?*?*?*??**??*?*?*?*??*?*?*?*?*?*?*?*??**
////Testing of Erase method
/////?*?*?*??*?*?*?*?*?*??*?*??*?*?*??*?*?*?*?*?*?*??*?*?*?*?*?*?*?*??**
cout<<"This is erase Method Test End"<<endl;
cout<<endl;
//////?*?*?*??*?*?*?*??*?*?*?*?*?*?*?*??**??*?*?*?*??*?*?*?*?*?*?*?*??**
////Testing of Clear method Uncomment to run it
cout<<"This is the size Method Test Start"<<endl;
cout<<ary.size()<<endl;
//////?*?*?*??*?*?*?*??*?*?*?*?*?*?*?*??**??*?*?*?*??*?*?*?*?*?*?*?*??**
////Testing of size method
/////?*?*?*??*?*?*?*?*?*??*?*??*?*?*??*?*?*?*?*?*?*??*?*?*?*?*?*?*?*??**
cout<<"This is size Method Test End"<<endl;
cout<<endl;
cout<<endl;
//////?*?*?*??*?*?*?*??*?*?*?*?*?*?*?*??**??*?*?*?*??*?*?*?*?*?*?*?*??**
////Testing of empty method
/////?*?*?*??*?*?*?*?*?*??*?*??*?*?*??*?*?*?*?*?*?*??*?*?*?*?*?*?*?*??**
cout<<"This is the empty Method Test Start"<<endl;
cout<<ary.empty()<<endl;
cout<<"This is empty Method Test End"<<endl;
cout<<endl;
//////?*?*?*??*?*?*?*??*?*?*?*?*?*?*?*??**??*?*?*?*??*?*?*?*?*?*?*?*??**
////Testing of at method
/////?*?*?*??*?*?*?*?*?*??*?*??*?*?*??*?*?*?*?*?*?*??*?*?*?*?*?*?*?*??**
cout<<"This is the at Method Test Start"<<endl;
cout<<ary.at(2)<<endl;
cout<<"This is at Method Test End"<<endl;
cout<<endl;
 
//////?*?*?*??*?*?*?*??*?*?*?*?*?*?*?*??**??*?*?*?*??*?*?*?*?*?*?*?*??**
////Testing of overloaded [] Operator
/////?*?*?*??*?*?*?*?*?*??*?*??*?*?*??*?*?*?*?*?*?*??*?*?*?*?*?*?*?*??**
cout<<"This is the [] operator Test Start"<<endl;
cout<<ary.operator [](2)<<endl;
cout<<"This is at Method Test End"<<endl;
cout<<endl;
 
//////?*?*?*??*?*?*?*??*?*?*?*?*?*?*?*??**??*?*?*?*??*?*?*?*?*?*?*?*??**
////Testing of Descending and ascending algorithm test
/////?*?*?*??*?*?*?*?*?*??*?*??*?*?*??*?*?*?*?*?*?*??*?*?*?*?*?*?*?*??**
//
cout<<"This is unsorted array"<<endl;
dynarray<T> aryy;
aryy.insert(4.0,0);
aryy.insert(6.0,1);
aryy.insert(3.0,2);
aryy.insert(7.0,3);
cout<<aryy<<endl;
cout<<"This is asending sorted array"<<endl;
aryy.ascendSort();
cout<<endl;
cout<<"This is desending sorted array"<<endl;
aryy.descendSort(
				 );
cout<<endl;

_____________________________________________________

compile output:


1>------ Build started: Project: dynarray, Configuration: Debug Win32 ------
1>Compiling...
1>dynarray.cpp
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(28) : error C2061: syntax error : identifier 'itemType'
1> c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(73) : see reference to class template instantiation 'dynarray<T>' being compiled
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(36) : error C2061: syntax error : identifier 'itemType'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(46) : error C2143: syntax error : missing ';' before '&'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(46) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(46) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(46) : warning C4183: 'at': missing return type; assumed to be a member function returning 'int'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(68) : error C2461: 'dynarray<T>' : constructor syntax missing formal parameters
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(153) : error C2244: 'dynarray<T>::push_back' : unable to match function definition to an existing declaration
1> c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(28) : see declaration of 'dynarray<T>::push_back'
1> definition
1> 'void dynarray<T>::push_back(T)'
1> existing declarations
1> 'void dynarray<T>::push_back(void)'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(199) : error C2244: 'dynarray<T>::insert' : unable to match function definition to an existing declaration
1> c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(36) : see declaration of 'dynarray<T>::insert'
1> definition
1> 'void dynarray<T>::insert(T,int)'
1> existing declarations
1> 'void dynarray<T>::insert(void)'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(235) : error C2244: 'dynarray<T>::getCap' : unable to match function definition to an existing declaration
1> c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(31) : see declaration of 'dynarray<T>::getCap'
1> definition
1> 'int dynarray<T>::getCap(void) const'
1> existing declarations
1> 'int dynarray<T>::getCap(void)'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(242) : error C2039: 'getSize' : is not a member of 'dynarray<T>'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(266) : error C2039: 'reSize' : is not a member of 'dynarray<T>'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(279) : error C2039: 'printArray' : is not a member of 'dynarray<T>'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(297) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(297) : error C2143: syntax error : missing ',' before '&'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(312) : error C2244: 'dynarray<T>::operator +' : unable to match function definition to an existing declaration
1> c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(54) : see declaration of 'dynarray<T>::operator +'
1> definition
1> 'dynarray<T> &dynarray<T>::operator +(const int)'
1> existing declarations
1> 'dynarray<T> dynarray<T>::operator +(const dynarray<T> &)'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(346) : error C2039: 'ascendSort' : is not a member of 'dynarray<T>'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(370) : error C2039: 'descendSort' : is not a member of 'dynarray<T>'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(373) : error C2065: 'T' : undeclared identifier
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(373) : error C2133: 'ary' : unknown size
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(373) : error C2512: 'dynarray' : no appropriate default constructor available
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(374) : error C2660: 'dynarray<T>::insert' : function does not take 2 arguments
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(375) : error C2660: 'dynarray<T>::insert' : function does not take 2 arguments
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(376) : error C2660: 'dynarray<T>::insert' : function does not take 2 arguments
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(377) : error C2660: 'dynarray<T>::insert' : function does not take 2 arguments
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(382) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'dynarray' (or there is no acceptable conversion)
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(653): could be 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(700): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(738): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(785): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(909): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const signed char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(916): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,signed char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(923): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const unsigned char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(930): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,unsigned char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(170): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ostream<_Elem,_Traits> &(__cdecl *)(std::basic_ostream<_Elem,_Traits> &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(176): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ios<_Elem,_Traits> &(__cdecl *)(std::basic_ios<_Elem,_Traits> &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(183): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::ios_base &(__cdecl *)(std::ios_base &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(190): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::_Bool)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(210): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(short)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(243): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned short)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(263): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 int)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(288): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 unsigned int)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(308): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(328): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 unsigned long)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(349): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__int64)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(369): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned __int64)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(390): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(float)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(410): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(double)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(430): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long double)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(450): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(const void *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(470): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_streambuf<_Elem,_Traits> *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> while trying to match the argument list '(std::ostream, dynarray)'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(384) : error C2660: 'dynarray<T>::push_back' : function does not take 1 arguments
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(385) : error C2660: 'dynarray<T>::push_back' : function does not take 1 arguments
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(387) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'dynarray' (or there is no acceptable conversion)
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(653): could be 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(700): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(738): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(785): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(909): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const signed char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(916): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,signed char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(923): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const unsigned char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(930): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,unsigned char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(170): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ostream<_Elem,_Traits> &(__cdecl *)(std::basic_ostream<_Elem,_Traits> &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(176): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ios<_Elem,_Traits> &(__cdecl *)(std::basic_ios<_Elem,_Traits> &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(183): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::ios_base &(__cdecl *)(std::ios_base &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(190): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::_Bool)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(210): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(short)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(243): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned short)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(263): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 int)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(288): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 unsigned int)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(308): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(328): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 unsigned long)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(349): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__int64)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(369): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned __int64)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(390): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(float)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(410): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(double)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(430): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long double)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(450): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(const void *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(470): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_streambuf<_Elem,_Traits> *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> while trying to match the argument list '(std::ostream, dynarray)'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(394) : error C2662: 'dynarray<T>::erase' : cannot convert 'this' pointer from 'dynarray' to 'dynarray<T> &'
1> Reason: cannot convert from 'dynarray' to 'dynarray<T>'
1> Conversion requires a second user-defined-conversion operator or constructor
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(403) : error C2662: 'dynarray<T>::size' : cannot convert 'this' pointer from 'dynarray' to 'const dynarray<T> &'
1> Reason: cannot convert from 'dynarray' to 'const dynarray<T>'
1> Conversion requires a second user-defined-conversion operator or constructor
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(414) : error C2662: 'dynarray<T>::empty' : cannot convert 'this' pointer from 'dynarray' to 'const dynarray<T> &'
1> Reason: cannot convert from 'dynarray' to 'const dynarray<T>'
1> Conversion requires a second user-defined-conversion operator or constructor
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(421) : error C2662: 'dynarray<T>::at' : cannot convert 'this' pointer from 'dynarray' to 'const dynarray<T> &'
1> Reason: cannot convert from 'dynarray' to 'const dynarray<T>'
1> Conversion requires a second user-defined-conversion operator or constructor
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(429) : error C2663: 'dynarray<T>::operator []' : 2 overloads have no legal conversion for 'this' pointer
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(438) : error C2065: 'T' : undeclared identifier
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(438) : error C2133: 'aryy' : unknown size
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(438) : error C2512: 'dynarray' : no appropriate default constructor available
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(439) : error C2660: 'dynarray<T>::insert' : function does not take 2 arguments
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(440) : error C2660: 'dynarray<T>::insert' : function does not take 2 arguments
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(441) : error C2660: 'dynarray<T>::insert' : function does not take 2 arguments
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(442) : error C2660: 'dynarray<T>::insert' : function does not take 2 arguments
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(443) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'dynarray' (or there is no acceptable conversion)
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(653): could be 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(700): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(738): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(785): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(909): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const signed char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(916): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,signed char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(923): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,const unsigned char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(930): or 'std::basic_ostream<_Elem,_Traits> &std::operator <<<std::char_traits<char>>(std::basic_ostream<_Elem,_Traits> &,unsigned char)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(170): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ostream<_Elem,_Traits> &(__cdecl *)(std::basic_ostream<_Elem,_Traits> &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(176): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_ios<_Elem,_Traits> &(__cdecl *)(std::basic_ios<_Elem,_Traits> &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(183): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::ios_base &(__cdecl *)(std::ios_base &))'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(190): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::_Bool)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(210): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(short)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(243): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned short)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(263): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 int)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(288): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 unsigned int)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(308): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(328): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__w64 unsigned long)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(349): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(__int64)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(369): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(unsigned __int64)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(390): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(float)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(410): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(double)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(430): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(long double)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(450): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(const void *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files\microsoft visual studio 9.0\vc\include\ostream(470): or 'std::basic_ostream<_Elem,_Traits> &std::basic_ostream<_Elem,_Traits>::operator <<(std::basic_streambuf<_Elem,_Traits> *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> while trying to match the argument list '(std::ostream, dynarray)'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(445) : error C2039: 'ascendSort' : is not a member of 'dynarray'
1> c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(18) : see declaration of 'dynarray'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(448) : error C2039: 'descendSort' : is not a member of 'dynarray'
1> c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(18) : see declaration of 'dynarray'
1>c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.cpp(7) : fatal error C1075: end of file found before the left brace '{' at 'c:\users\makhdoom shah\documents\visual studio 2008\projects\dynarray\dynarray\dynarray.h(372)' was matched
1>Build log was saved at "file://c:\Users\Makhdoom Shah\Documents\Visual Studio 2008\Projects\dynarray\dynarray\Debug\BuildLog.htm"
1>dynarray - 44 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

So...did you even try to understand and correct the errors you're getting before posting all of that (without code tags)?

Programmers are always confused. It's a fact of life. So start at the top and go one error at a time. Often one error will cause others, and the cascade effect overwhelms you. So don't treat it as 44 errors and 1 warning that you don't understand, treat it as

dynarray.h(28) : error C2061: syntax error : identifier 'itemType'

Ask yourself, "what is itemType?", and "why wouldn't my compiler recognize it?".

Comments
A good piece of advise, should (somehow) be made clear to all the beginners
This question has already been answered. Start a new discussion instead.