--- a/include/vector.h Tue Apr 22 13:33:12 2008 +0200
+++ b/include/vector.h Wed Apr 23 10:38:33 2008 +0200
@@ -30,6 +30,8 @@
#include <math.h>
#include <iostream>
+#include "common.h"
+
using namespace std;
/**
@@ -166,10 +168,24 @@
return Vector3(a.x * b.x, a.y * b.y, a.z * b.z);
};
- // print
+ // write
friend ostream & operator<<(ostream &st, const Vector3 &v)
{
- return st << "(" << v.x << ", " << v.y << ", " << v.z << ")";
+ return st << "(" << v.x << "," << v.y << "," << v.z << ")";
+ };
+
+ // read
+ friend istream & operator>>(istream &st, Vector3 &v)
+ {
+ char s[10];
+ st.getline(s, 10, '(');
+ st >> v.x;
+ st.getline(s, 10, ',');
+ st >> v.y;
+ st.getline(s, 10, ',');
+ st >> v.z;
+ st.getline(s, 10, ')');
+ return st;
};
};