Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
RogueReborn
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mikhail Andrenkov
RogueReborn
Commits
12ddb5d6
Commit
12ddb5d6
authored
8 years ago
by
Ian Prins
Browse files
Options
Downloads
Patches
Plain Diff
Implement Coord.h
parent
e428a172
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/coord.cpp
+26
-0
26 additions, 0 deletions
src/coord.cpp
src/include/coord.h
+3
-2
3 additions, 2 deletions
src/include/coord.h
with
29 additions
and
2 deletions
src/coord.cpp
0 → 100644
+
26
−
0
View file @
12ddb5d6
#include
"include/coord.h"
#include
<string>
Coord
::
Coord
(
int
x
,
int
y
)
:
x
(
x
)
,
y
(
y
)
{}
int
&
Coord
::
operator
[](
int
dimension
)
{
switch
(
dimension
)
{
case
0
:
return
this
->
x
;
case
1
:
return
this
->
y
;
}
throw
"bad dimension "
+
std
::
to_string
(
dimension
);
return
this
->
x
;
}
Coord
Coord
::
operator
+
(
const
Coord
&
other
)
{
return
Coord
(
this
->
x
+
other
.
x
,
this
->
y
+
other
.
y
);
}
Coord
Coord
::
operator
-
(
const
Coord
&
other
)
{
return
Coord
(
this
->
x
-
other
.
x
,
this
->
y
-
other
.
y
);
}
This diff is collapsed.
Click to expand it.
src/include/coord.h
+
3
−
2
View file @
12ddb5d6
...
...
@@ -4,9 +4,10 @@
class
Coord
{
public:
Coord
(
int
,
int
);
int
&
operator
[](
int
);
Coord
operator
+
(
Coord
);
Coord
operator
-
(
Coord
);
Coord
operator
+
(
const
Coord
&
);
Coord
operator
-
(
const
Coord
&
);
private:
int
x
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment