summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--number.cpp19
-rw-r--r--number.h14
2 files changed, 33 insertions, 0 deletions
diff --git a/number.cpp b/number.cpp
index c337a34..57dbcae 100644
--- a/number.cpp
+++ b/number.cpp
@@ -149,6 +149,25 @@ number::operator!=(const number &n) const
}
/* }}} */
+/* Assignment operators {{{ */
+
+number &
+number::operator+=(const number &n)
+{
+ *this = *this + n;
+
+ return *this;
+}
+
+number &
+number::operator++()
+{
+ *this = *this + 1;
+
+ return *this;
+}
+
+/* }}} */
std::ostream &
operator<<(std::ostream &os, const number &n)
diff --git a/number.h b/number.h
index 252428a..c905287 100644
--- a/number.h
+++ b/number.h
@@ -11,6 +11,8 @@ public:
number(const number &) = default;
number(number &&) = default;
+ number &operator=(const number &) = default;
+
number(std::uint32_t);
/**
@@ -78,6 +80,18 @@ public:
*/
bool operator!=(const number &n) const;
+ /**
+ * \brief Add a number to this number.
+ *
+ * \param n Number to add to this number.
+ */
+ number &operator+=(const number &n);
+
+ /**
+ * \brief Increment this number.
+ */
+ number &operator++();
+
private:
/* First item is the least significant. */
std::list<std::uint32_t> _operands;