-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add increment and decrement operators
- Loading branch information
Showing
2 changed files
with
74 additions
and
4 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
=========================================================================== | ||
Increment and decrement operators | ||
=========================================================================== | ||
*/ | ||
|
||
#ifndef BIG_INT_INCREMENT_DECREMENT_OPERATORS_HPP | ||
#define BIG_INT_INCREMENT_DECREMENT_OPERATORS_HPP | ||
|
||
#include "BigInt.hpp" | ||
#include "constructors/constructors.hpp" | ||
#include "operators/assignment.hpp" | ||
#include "operators/arithmetic_assignment.hpp" | ||
#include "operators/binary_arithmetic.hpp" | ||
|
||
|
||
/* | ||
Pre-increment | ||
------------- | ||
++BigInt | ||
*/ | ||
|
||
BigInt& BigInt::operator++() { | ||
*this += 1; | ||
|
||
return *this; | ||
} | ||
|
||
|
||
/* | ||
Pre-decrement | ||
------------- | ||
--BigInt | ||
*/ | ||
|
||
BigInt& BigInt::operator--() { | ||
*this -= 1; | ||
|
||
return *this; | ||
} | ||
|
||
|
||
/* | ||
Post-increment | ||
-------------- | ||
BigInt++ | ||
*/ | ||
|
||
BigInt BigInt::operator++(int) { | ||
BigInt temp = *this; | ||
*this += 1; | ||
|
||
return temp; | ||
} | ||
|
||
|
||
/* | ||
Post-decrement | ||
-------------- | ||
BigInt-- | ||
*/ | ||
|
||
BigInt BigInt::operator--(int) { | ||
BigInt temp = *this; | ||
*this -= 1; | ||
|
||
return temp; | ||
} | ||
|
||
#endif // BIG_INT_INCREMENT_DECREMENT_OPERATORS_HPP |