The SimpleCxxLib package


#include "point.h"

class Point

This class represents an x-y coordinate point on a two-dimensional integer grid. If you need to work with real-valued points, you should use the gtypes.h interface instead.
Constructor
Point()
Point(x, y) 
Creates a Point object with the specified x and y coordinates.
Methods
getX() Returns the x-coordinate of the point.
getY() Returns the y-coordinate of the point.
toString() Returns a string representation of the Point in the form "(x, y)".
Operator
cout << pt; Overloads the << operator so that it is able to display Point values.

Constructor detail


Point();
Point(int x, int y);
Creates a Point object with the specified x and y coordinates. If the coordinates are not supplied, the default constructor sets these fields to 0.

Usage:

Point origin;
Point pt(x, y);

Method detail


int getX() const;
Returns the x-coordinate of the point.

Usage:

int x = pt.getX();

int getY() const;
Returns the y-coordinate of the point.

Usage:

int y = pt.getY();

string toString() const;
Returns a string representation of the Point in the form "(x, y)".

Usage:

string str = pt.toString();

Operator detail


ostream & operator<<(ostream & os, const Point & pt);
Overloads the << operator so that it is able to display Point values.

Usage:

cout << pt;