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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access