diff options
Finished todays practice
1 files changed, 29 insertions, 0 deletions
| -rw-r--r-- | Year 1/Object-oriented Programming/10-Practice-03.05.2022/source.cpp | 29 |
diff --git a/Year 1/Object-oriented Programming/10-Practice-03.05.2022/source.cpp b/Year 1/Object-oriented Programming/10-Practice-03.05.2022/source.cpp new file mode 100644 index 0000000..48807c0 --- /dev/null +++ b/Year 1/Object-oriented Programming/10-Practice-03.05.2022/source.cpp @@ -0,0 +1,29 @@ +#include "MergeSort.hpp" +#include <iostream> + +class Num { + int n; + +public: + Num() : Num(0) {} + Num(unsigned n) { + this->n = n; + } + unsigned get_n() const { return n; } +}; + +bool operator<(const Num& n1, const Num& n2) { + return n1.get_n() < n2.get_n(); +} + +std::ostream& operator<<(std::ostream& ostr, const Num& num) { + return ostr << num.get_n(); +} + +int main() { + const unsigned size = 3; + Num arr[] = { 7, 2, 9 }; + Num* sorted = mergeSort(arr, size); + for (int i = 0; i < size; i++) + std::cout << sorted[i] << " "; +} |
