Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string>
- #include <compare>
- using namespace std::literals::string_literals;
- class Stump {
- public:
- Stump(int val = 0) : val_ { val } {};
- Stump(Stump const & stmp) = default;
- Stump(Stump && stmp) = default;
- Stump & operator=(Stump const & stmp) = default;
- Stump & operator=(Stump && stmp) = default;
- auto operator <=>(Stump const & that) const {
- return val_ <=> that.val_;
- }
- auto operator==(Stump const & that) const {
- return val_ == that.val_;
- }
- int val(int val) {
- val_ = val;
- return val_;
- }
- int val(void) const {
- return val_;
- }
- private:
- int val_;
- };
- int main() {
- std::cout << "C++ Version: "s << __cplusplus << std::endl;
- int av;
- int bv;
- std::cout << "Enter two integer values: "s;
- std::cout.flush();
- std::cin >> av >> bv;
- std::cout << std::endl;
- std::cout << "Input: "s << av << ' ' << bv << '\n';
- auto ay = Stump(av);
- auto be = Stump(bv);
- std::cout << ay.val() << " is"s
- << ((ay < be) ? " less than "s :
- (ay > be) ? " greater than "s :
- " equal to "s)
- << be.val()
- << std::endl;
- std::cout << ay.val() << " is"s
- << ((ay <= be) ? " less than or equal to "s :
- (ay >= be) ? " greater than or equal to "s :
- " not LE and not GE to "s)
- << be.val()
- << std::endl;
- std::cout << ay.val() << " is"s
- << ((ay != be) ? " not equal to "s :
- (ay == be) ? " equal to "s :
- " not NE and not EQ to "s)
- << be.val()
- << std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement