struct GridLocation
row
and col
. A GridLocation can be used to
represent a location in a two-dimensional grid.
Fields | |
Constructor | |
GridLocation(row, col) | Creates a GridLocation with the specified row and col . |
Methods | |
Returns a printable string representation of this GridLocation . | Operators |
Returns true if loc1 and loc2 are the same location. |
|
Returns true if loc1 and loc2 are different locations. |
|
Outputs the location to the given output stream. | |
Reads a location from the given input stream. |
GridLocation(); GridLocation(int row, int col);
GridLocation
object with the specified row
and col
location. If the row and col are not supplied,
the default constructor sets these fields to 0. The GridLocation fields row
and
col
can also directly accessed using dot notation.
Usage:
GridLocation origin; GridLocation loc(5, 10); origin.col = 0; if (loc.row == loc.col) ...
string toString() const;
"r5c8"
.
Usage:
string str = loc.toString();
ostream& operator<<(const GridLocation& loc);Outputs the
GridLocation
to the given output stream.
The output is in the form r5c8
.
Usage:
cout << loc << endl;
istream& operator>>(GridLocation& loc);Reads a GridLocation from the given input stream. The input is expected to be in the form
r5c8
. If unable to read a proper
location from the stream, the operation results in a stream fail state.
Usage:
if (infile >> loc) ...