I wrote two operators
Code:
template <class T>
Vector<T>& operator+( const Vector<T>& vec, const T& value )
{
Vector<T> tempvec(vec.length()); //create temp vector
for(int counter=0; counter<vec.length(); counter++)
tempvec.SetSpecificValue(counter, value+vec.GetSpecificValue(counter));
return tempvec;
}
template <class T>
Vector<T>& Vector<T>::operator=( const T& value )
{
for(int counter=0; counter<capacity; counter++)
{
array[counter] = value;
}
return *this;
}
I know that the equal operator is working because
Code:
vec4//already exists
Vector<int> vec6(vec4.length());
vec6.print();
vec6 = vec4;
vec6.print();
Is working!
But the following does not
Code:
vec6 = vec4 + 5;
vec6.print();
Any ideas???
Thanks.