In this exercise I am using Visual Studio 2017 and a modified version of the std_lib_facilities header found here.
Chapter 19 // Exercise 5
Define a class Int having a single member of class int. Define constructors, assignment, and operators +, -, *, / for it. Test it, and improve its design as needed (e.g., define operators << and >> for convenient I/O).
I think I went a bit overboard with the operator overloading on this one. I tried searching but I couldn't find if there is a way to reduce the amount of overloading as I only want two types allowed; int and Int. I thought about using type_traits and templating the class but then that would mean Int would need a type when declared which isn't in the brief.
No comments:
Post a Comment