Guest User

Untitled

a guest
Dec 15th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. bool Vector3D::operator< (const Vector3D& other) const
  2. {
  3. for(int k = 0; k < NUM_COORDINATES; ++k)
  4. if(coordinates[k] < other.coordinates[k]) return true;
  5. return false;
  6. }
  7.  
  8. Vector3D.h
  9.  
  10. class Vector3D
  11. {
  12. public:
  13.  
  14. Vector3D();
  15.  
  16. void set(int arrayIndex,int num);
  17.  
  18. bool operator< (const Vector3D& other) const;
  19.  
  20. private:
  21.  
  22. static const int NUM_COORDINATES = 3;
  23. double coordinates[NUM_COORDINATES];
  24. };
  25.  
  26.  
  27.  
  28. Vector3D.cpp
  29.  
  30. #include "Vector3D.h"
  31.  
  32. Vector3D::Vector3D(void){
  33.  
  34. }
  35.  
  36.  
  37. void Vector3D::set(int arrayIndex,int num){
  38.  
  39. coordinates[arrayIndex]=num;
  40.  
  41.  
  42.  
  43. }
  44. bool Vector3D::operator< (const Vector3D& other) const
  45. {
  46. for(int k = 0; k < NUM_COORDINATES; ++k)
  47. if(coordinates[k] < other.coordinates[k]) return true;
  48. return false;
  49. }
Add Comment
Please, Sign In to add comment