#include using namespace std; // declaration class vector { private: float x,y,z; public: vector(float a=0, float b=0, float c=0) { x=a; y=b; z=c; }// vector() ~vector() {} // nothing to do :) void prtVec(); void getVec(float &a, float &b, float &c); void setVec(float &a, float &b, float &c); };// class vector inline void vector::getVec(float &a, float &b, float &c) { a=x; b=y; c=z; }// getVec() inline void vector::setVec(float &a, float &b, float &c) { x=a; y=b; z=c; }//setVec() // definitions void vector::prtVec() { cout << x << ", " << y << ", " << z << endl; }// prtVec() // standalone operator overloading, IDENTICAL to // sum() above! vector operator+(vector& a, vector& b) { float x0,y0,z0,x1,y1,z1; a.getVec(x0,y0,z0); b.getVec(x1,y1,z1); return vector(x0+x1,y0+y1,z0+z1); }// sum() class CoordSystem { public: vector xAxis,yAxis,zAxis; CoordSystem(float x0, float y0, float z0, float x1, float y1, float z1, float x2, float y2, float z2) { xAxis.setVec(x0,y0,z0); yAxis.setVec(x1,y1,z1); zAxis.setVec(x2,y2,z2); // note: a constructor fn does NOT need to return }// CoordSystem // more methods, eg. isOrthogonal(), }; // CoordSystem int main() { CoordSystem cart(1,0,0, 0,1,0, 0,0,1); cart.yAxis.prtVec(); return 0; }// main()