#include "Vector.hpp" Vector::Vector(int length) { size = length; array = new (nothrow) int[size]; if(array==NULL) { cerr << "Memory allocation failure!" << endl; exit(-1); } for(int i=0; ilength(); array = new (nothrow) int[size]; if(array==NULL) { cerr << "Memory allocation failure!" << endl; exit(-1); } for(int i=0; ivalueAt(i); } Vector::~Vector() { delete [] array; } int Vector::length() const { return size; } int &Vector::valueAt(int pos) const { if(pos>=length()) { cerr << "Invalid access position!\n"; return array[size-1]; } return array[pos]; } int Vector::find(int a) const { for(int i=0; i v.length()) length = size; else length = v.length(); Vector n(length); for(int i=0; i v.length()) length = size; else length = v.length(); Vector n(length); for(int i=0; i size) { Vector n(v); n = n + *this; *this = n; } else { *this = *this + v; } return *this; } Vector& Vector::operator+=(int a) { for(int i=0; i size) { Vector n(v); n = n - *this; *this = n; } else { *this = *this - v; } return *this; } Vector& Vector::operator-=(int a) { for(int i=0; i>=(int a) { for(int i=0; i>= a; return *this; } int &Vector::operator[](int pos) const { return array[pos]; }