Last active
February 9, 2020 10:24
-
-
Save RalXYZ/e7f6e895af4599b4f29afd318c8cdbfd to your computer and use it in GitHub Desktop.
Overload operators related to "plus"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// struct test already declared | |
const test test::operator++(int) { | |
test temp = *this; | |
this->a++; | |
return temp; | |
} | |
test& test::operator++() { | |
++this->a; | |
return *this; | |
} | |
test& test::operator+=(const test& temp) { | |
this->a += temp.a; | |
return *this; | |
} | |
test& test::operator+(const test& temp) const { | |
test sum; | |
sum.a = this->a + temp.a; | |
return sum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment