Homework 13 - Extra Credit

For this assignment there will be a class definition for our own integer list container called IntList. This class definition will practice the use of a dynamic member variable which means we will have to define a default constructor, copy constructor, destructor, and overload the assignment operator to avoid memory leaks and fulfill functionality.

Your task for this homework assignment is to hand write this class definition and all if its constructors, destructor, and member functions. Before you write the definition for each, write a brief summary for the purpose of the constructor, destructor, or member function and what that definition is doing. I've given you the full source code to the assignment with main to test each interface of the class. Copy, compile, and run the given program to familiarize yourself with the interface.

You must hand write and hand in your work before the due date.

hw13.cpp

/******************************************************************/
/* IntList ********************************************************/
/******************************************************************/
#define DEFAULT_SIZE 10
class IntList {
    private:
        int *list;                      //pointer to array
        int count;                      //num of elems in array
        int capacity;                   //capacity of array
        bool isValidIndex(const int) const;  //is passed index w/in range?
    public:
        IntList();
        IntList(const IntList&);
        IntList(const int);
        ~IntList();
        IntList& operator=(const IntList&);

        void setElement(const int, const int);
        const int getElement(const int) const;
        void append(const int);
        const int size() const;
        void printList() const;
        void debug() const;
};
/******************************************************************/