Assignment 2 includes a programming portion and a written portion. The programming portion must compile and should consist of a single file (hw02.cpp). The written portion should consist of a single file (hw02written) in a .pdf format. Be sure to include your name at the beginning of each
file! You must hand in both files via NYU Classes. No late assignments will be accepted.
Programming Part:
1. For the class called IntArray implement a deep copy constructor, a move constructor, a destructor, and a move assignment operators. Use the std::swap function if appropriate, and below where you used the std::swap function, write as a comment the code to perform the same steps without using the std::swap function.
Implement the methods outside the class interface.
You may implement the put and get methods to test your code. You will not be graded on these methods.
Nicolai, our TA, has created a unit test for this question.[2] Your code must pass this unit test. The unit test is in a file called main.cc.
class IntArray{ public:
IntArray(int n = 0): size(n), array(new int[n]){}
// add your methods here
void put (int i, int value); int get( int i); private:
int * array; int size;
};
2. Write a functor to determine if an integer is even or odd.
3. Write a functor that compares two strings, str1 and str2. If str1’s length is less than str2’s length, your functor returns true. Otherwise it returns false.
Written Part
1. What is printed if you ran the following code. Would this be what you wanted to happen? Is there anything that goes wrong?
class IntArray{ public:
IntArray(int n = 0): size(n), array(new int[n]){} void put (int i, int value); int get( int i); private: