Guest User

Untitled

a guest
Apr 24th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. Fails:
  2.  
  3. .h:
  4. namespace IBDS
  5. {
  6. public:
  7. friend Vector3D operator ^ (const Vector3D& a, const Vector3D& b);
  8. }
  9.  
  10. .cpp:
  11. Vector3D IBDS::operator ^ (const Vector3D& a, const Vector3D& b)
  12. {
  13. return Vector3D ( a.v[1]*b.v[2] - a.v[2]*b.v[1],
  14. a.v[2]*b.v[0] - a.v[0]*b.v[2],
  15. a.v[0]*b.v[1] - a.v[1]*b.v[0]);
  16. };
  17.  
  18.  
  19. => /ibds/Math/Vector3D.cpp:204: error: 'IBDS::Vector3D IBDS::operator^(const IBDS::Vector3D&, const IBDS::Vector3D&)' should have been declared inside 'IBDS'
  20.  
  21.  
  22. This works:
  23. .h:
  24. namespace IBDS
  25. {
  26. public:
  27. friend Vector3D operator ^ (const Vector3D& a, const Vector3D& b)
  28. {
  29. return Vector3D ( a.v[1]*b.v[2] - a.v[2]*b.v[1],
  30. a.v[2]*b.v[0] - a.v[0]*b.v[2],
  31. a.v[0]*b.v[1] - a.v[1]*b.v[0]);
  32. };
  33. }
  34.  
  35. .cpp:
  36. // nil
Add Comment
Please, Sign In to add comment