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
58d68d05
Commit
58d68d05
authored
8 years ago
by
Ian Prins
Browse files
Options
Downloads
Patches
Plain Diff
Add new arithmetic operators and a copy func
parent
ff2b004d
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
+12
-0
12 additions, 0 deletions
src/coord.cpp
src/include/coord.h
+3
-1
3 additions, 1 deletion
src/include/coord.h
with
15 additions
and
1 deletion
src/coord.cpp
+
12
−
0
View file @
58d68d05
...
...
@@ -11,6 +11,10 @@ Coord::Coord()
,
y
(
0
)
{}
Coord
Coord
::
copy
()
{
return
Coord
(
x
,
y
);
}
int
&
Coord
::
operator
[](
int
dimension
)
{
switch
(
dimension
)
{
case
0
:
...
...
@@ -29,3 +33,11 @@ Coord Coord::operator+(const Coord& other) {
Coord
Coord
::
operator
-
(
const
Coord
&
other
)
{
return
Coord
(
this
->
x
-
other
.
x
,
this
->
y
-
other
.
y
);
}
Coord
Coord
::
operator
+=
(
const
Coord
&
other
)
{
return
*
this
+
other
;
}
Coord
Coord
::
operator
-=
(
const
Coord
&
other
)
{
return
*
this
-
other
;
}
This diff is collapsed.
Click to expand it.
src/include/coord.h
+
3
−
1
View file @
58d68d05
...
...
@@ -9,7 +9,9 @@ class Coord {
int
&
operator
[](
int
);
Coord
operator
+
(
const
Coord
&
);
Coord
operator
-
(
const
Coord
&
);
Coord
operator
+=
(
const
Coord
&
);
Coord
operator
-=
(
const
Coord
&
);
Coord
copy
();
private:
int
x
;
int
y
;
...
...
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