Advertisement
avskyRB

RndWlk-Vettore.cxx

Sep 2nd, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include "Vettore.h"
  2. #include <iomanip>  
  3.  
  4. Vettore::Vettore()
  5. {
  6.   m_x = m_y = m_z = 0;
  7. }
  8.  
  9. Vettore::Vettore(double x, double y, double z)
  10. {
  11.   m_x = x;
  12.   m_y = y;
  13.   m_z = z;
  14. }
  15.  
  16. Vettore Vettore::operator+(const Vettore& v)
  17. {
  18.   return Vettore( m_x + v.m_x, m_y + v.m_y, m_z + v.m_z);
  19. }
  20.  
  21.  
  22.  
  23. std::ostream& operator<<(std::ostream& o, Vettore& v)
  24. {
  25.   o.setf(std::ios::showpos);  
  26.   o << std::scientific;      
  27.   o << std::setprecision(4);  
  28.   o << "("
  29.     << std::setw(10) << v.x() << ", "  
  30.     << std::setw(10) << v.y() << ", "
  31.     << std::setw(10) << v.z() << ")";  
  32.   o << "|" << v.modulo() << "|";  
  33.   return o;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement