From 3339c6030bc30f89c454f228eaac3864a9993b7a Mon Sep 17 00:00:00 2001 From: Mikenekro Date: Fri, 10 Mar 2017 12:12:06 -0600 Subject: [PATCH] Added Vector Addition Operator Overload Added a new Vector Addition Operator Overload to add two vectors elements into a new Vector --- Vector.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Vector.h b/Vector.h index 45b961b..9dafdbe 100644 --- a/Vector.h +++ b/Vector.h @@ -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& operator+(Vector& 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 { @@ -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];