Advertisement
Guest User

Untitled

a guest
Sep 20th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. template<class T>
  2. bool &operator == (const MSArray<T> &vec1, const MSArray<T> &vec2)
  3. {
  4.     if (vec1.size() != vec2.size()) // if the two MSArrays arent even the same size
  5.     {                               // just leave because they can't be equal
  6.         return false;
  7.     }
  8.     for (int i = 0; i < vec1.size(); ++i)
  9.     {
  10.         if (vec1.msarray_[i] != vec2.msarray_[i])//go through the whole vector and if each elment is equivalent
  11.         {                      //then it won't return false and will break from the loop
  12.             return false;
  13.         }
  14.     }
  15.     return true; // the size was the same and all elments were same so they are ==
  16. }
  17.  
  18. template<class T>
  19. bool &operator!=(const MSArray<T> &vec1, const MSArray<T> &vec2)
  20. {
  21.     return !(vec1 == vec2) // return the opposite of == operator
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement