#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) { a=x; b=y; c=z; }// getVec() };// class vector // definitions void vector::prtVec() { cout << x << ", " << y << ", " << z << endl; }// prtVec() 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); }// operator+() int main() { vector v(1,2,3); // constructed with 0,0,0 vector *vecPtr = &v; // ptr to v v.prtVec(); (*vecPtr).prtVec(); // less common syntax vecPtr->prtVec(); // more common syntax float x,y,z; vecPtr->getVec(x,y,z); // 'pointer to member' syntax again cout << x << " " << y << " " << z << endl; return 0; }// main()