1. Develop a class smartArray with the following members: (5p)
public:
int *elements // dynamic array, memory is allocated in the constructor. Use *this
to access size member.
int length() // returns the length of the array
smartArray() // default constructor, sets size to 0
smartArray(int size) // constructor, allocates the memory for *elements, if size==0, then
no memory allocation is done
~smartArray() // destructor
private:
int size // number of the elements in the array
2. Overload << and >> operators (10p)
overload operator << to print the array contents in the following format:
[33,66,23,63,75,23] (example)
overload operator >> to read the array elements from the keyboard. Format:
enter element 1:
enter element 2:
etc.
My problem with my code is I can't figure out how to use the length() function to return size and implement it into the code. What I have right now works but it's not using the length() function, its just using the this-> pointer for size.