direction.h
Direction
whose elements are the four compass points: NORTH
,
EAST
, SOUTH
, and WEST
.
Type | |
This enumerated type is used to represent the four compass directions. | |
Functions | |
Returns the name of the direction as a string. | |
Returns the direction that is to the left of the argument. | |
Returns the direction that is opposite to the argument. | |
Returns the direction that is to the right of the argument. |
enum Direction { NORTH, EAST, SOUTH, WEST };
Direction leftFrom(Direction dir);
Usage:
Direction newdir = leftFrom(dir);
Direction rightFrom(Direction dir);
Usage:
Direction newdir = rightFrom(dir);
Direction opposite(Direction dir);
Usage:
Direction newdir = opposite(dir);
string directionToString(Direction dir);
Usage:
string str = directionToString(dir);