//  declaration & implementation & application for class My3Vector
//  T3VectorAllInclusive.cpp
//
#include <iostream> // pre-prozessor command 
#include <cmath> // pre-prozessor command 

using namespace std; // declare namespace

class My3Vector {
 private:        // coordinates, hidden
  double x;
  double y;
  double z;
 public:  
  My3Vector() { // default constructor
    x = 0.; y = 0.; z = 0.; // set coords to 0.
  };
  My3Vector(double c1, double c2, double c3) {// Other constructor
  x = c1; y = c2; z = c3; // take args for coords
  };
  // methods:
  // get length of vector
  double Length() {  
    return( sqrt( x*x + y*y +z*z ) );
  };
  // access elements
  double X() { return x; };
  double Y() { return y; };
  double Z() { return z; };
  // add
  My3Vector Add( My3Vector & p ) {
    My3Vector t; 
    t.x = x + p.x;   t.y = y + p.y;   t.z = z + p.z;
    return( t );
  };
  // print
  void Print( ) {
    cout << "( " << x << ", " << y << ", " << z << " )" << endl;
  };
};


int main() 
{
  My3Vector a, b(1.,1.,-1.), c(0.,2.,1.); // create 3 ThreeVec objects
  a = b.Add(c); // add ThreeVec b and c, result is stored in a
  cout << a.Length() << endl;

  a.Print();
  b.Print();
  c.Print();
}