#include <iostream> #include <fstream> using namespace std; /********************************************* ** PROTOTYPES & STRUCT DEFINITIONS *********************************************/ struct point { double x, y; }; void read(point &p, istream &IN); void write(point p, ostream &OUT); point operator+(point a, point b); point operator/(point P, double z); ostream& operator<<(ostream& OUT, point p); istream& operator>>(istream& IN, point &p); struct Quad { char label; point *vert; }; int main() { // Create quadrilateral S Quad S; S.vert = new point[4]; // Read label and vertices cout << "Enter label and 4 vertices: "; cin >> S.label; for(int i = 0; i < 4; i++) cin >> S.vert[i]; // Write label and vertices cout << "Your quadrilateral is " << S.label << " "; for(int j = 0; j < 4; j++) cout << S.vert[j] << ' '; cout << endl; return 0; } /********************************************* ** FUNCTION DEFINITIONS *********************************************/ void read(point &p, istream &IN) { char c; IN >> c >> p.x >> c >> p.y >> c; } void write(point p, ostream &OUT) { OUT << '(' << p.x << ',' << p.y << ')'; } point operator+(point a, point b) { point S; S.x = a.x + b.x; S.y = a.y + b.y; return S; } point operator/(point P, double z) { point Q; Q.x = P.x / z; Q.y = P.y / z; return Q; } ostream& operator<<(ostream& OUT, point p) { write(p,OUT); return OUT; } istream& operator>>(istream& IN, point &p) { read(p,IN); return IN; }