From cba45f29a20a043648539b1d342c0ef0c3764284 Mon Sep 17 00:00:00 2001 From: josh Date: Fri, 16 Jan 2009 00:55:28 +0000 Subject: [PATCH] updated Vector git-svn-id: svn://anubis/gvsu@357 45c1a28c-8058-47b2-ae61-ca45b979098e --- cs658/final/util/Vector.cc | 16 ++++++++++++++++ cs658/final/util/Vector.h | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/cs658/final/util/Vector.cc b/cs658/final/util/Vector.cc index e69de29..91787ff 100644 --- a/cs658/final/util/Vector.cc +++ b/cs658/final/util/Vector.cc @@ -0,0 +1,16 @@ + +#include "Vector.h" +#include + +Vector::Vector() +{ + m_array[0] = 0.0; + m_array[1] = 0.0; + m_array[2] = 0.0; +} + +std::ostream & operator<<(std::ostream & out, const Vector & v) +{ + out << "[" << v[0] << ", " << v[1] << ", " << v[2] << "]"; + return out; +} diff --git a/cs658/final/util/Vector.h b/cs658/final/util/Vector.h index e69de29..8726e92 100644 --- a/cs658/final/util/Vector.h +++ b/cs658/final/util/Vector.h @@ -0,0 +1,20 @@ + +#ifndef VECTOR_H +#define VECTOR_H VECTOR_H + +#include + +class Vector +{ + public: + Vector(); + ~Vector(); + double & operator[](int idx) { return m_array[idx]; } + double operator[](int idx) const { return m_array[idx]; } + friend std::ostream & operator<<(std::ostream & out, const Vector & v); + + private: + double m_array[3]; +}; + +#endif