Skip to content

Commit

Permalink
Added Vector Addition Operator Overload
Browse files Browse the repository at this point in the history
Added a new Vector Addition Operator Overload to add two vectors
elements into a new Vector
  • Loading branch information
Mikenekro committed Mar 10, 2017
1 parent 7138a85 commit 3339c60
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,16 @@ namespace std
return *this;
}

// Adds the right Vectors elements to the left Vectors elements
// Ex. vec = vec2 (1, 2, 3) + vec3 (4, 5, 6); which makes vec = (1, 2, 3, 4 ,5 ,6)
const Vector<T>& operator+(Vector<T>& x)
{
for (int i = 0; i < x.size; ++i)
Push_Back(x[i]);

return *this;
}

// Returns the size of this vector (starting at 1)
const uint Size() const
{
Expand Down Expand Up @@ -628,7 +638,7 @@ namespace std
{
// Loop from the position after this element,
// to the last element in the Vector
for (int i = pos; (uint)i < size-1; ++i)
for (uint i = (uint)pos; i < size-1; ++i)
{
// Switch the elements
T temp = element[i];
Expand Down

0 comments on commit 3339c60

Please sign in to comment.