You are wrong assuming that in line
cout << "a =" << (*v)[0] << endl;
The
const value_type & Vector::operator[] ( long index ) const
will be used.
In fact both times
value_type & Vector::operator[]
is used so you "replace" previous value with new (and leaking memory at the same time)
below should help
value_type & Vector<value_type>::operator[] ( long index ) {
if ( index < 0 || index > usedSize )
///out of bounds handling
else {
if(vector[index]== 0)
{
vector[index] = new value_type () ;
usedSize++ ;
}
return *(vector[index]) ;
}
}