24.4 GEOMETRY

class Point

    { private :      int xc, yc;    public:      Point(int i, int j);      Point();      void show();      friend ostream & operator << ( ostream & temp, POINT & p);  };

The basic entity in any graphical program is “point”. Co-ordinates are normally plotted on paper or drawn on screen. Hence, their data type is selected as int. If some application needs large values, type may be replaced by “long”.

If needed, additional field named scale can be added. It may specify units such as mm, cm, etc.

class Polar

    { private :      double mag, ang ;    public :      Polar( double magnitude, double angle )         {   mag = magnitude;             ang = angle ;         }      void show();      friend void polar_to_rect(polar ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.