so I can say output << a << endl;
and it will print the contents of the object a... which happens to be an array.
class info:
Expand|Select|Wrap|Line Numbers
- class List
- {
- public:
- List();
- bool empty(); //returns true of false if empty
- void front(); //makes current position at beginning of list
- void end(); //makes current position at the end of list
- void prev(); //places current position at the previous element in the list
- void next(); //places current position at the next element in the list
- int getPos(); //returns current position or where you are in the list
- int SetPos(int); //places current position in a certain position in the list
- void insertBefore(int); //inserts a new element before the current position
- void insertAfter(int); //inserts a new element after the current position
- int getElement(); //returns the one element that current position is pointing to
- int size(); //returns the size of the list(number of elements in the list)
- void replace(int); //replace the current element with a new one
- void erase(); //deletes the current element
- void clear(); //makes the list an empty list
- void reverse(); //reverse elements in a list
- void swap(List); //swaps all the elements of one list with another list
- int getMax(); //return Max Size based on const CAPACITY
- void display(); //displays contents of list
- private:
- int current;
- int length;
- static const int CAPACITY = 20;
- int arrayList[CAPACITY];
- int arrayCopy[CAPACITY];
- };
constructor:
Expand|Select|Wrap|Line Numbers
- List::List()
- {
- //constructor - initialize array's at position 1
- int maxLen=CAPACITY;
- length=0;
- current=0;
- arrayList[length];
- arrayCopy[length];
- //clean up garbage...
- for(int i=0;i<CAPACITY;i++)
- {
- arrayList[i]=0;
- arrayCopy[i]=0;
- }
- }
Expand|Select|Wrap|Line Numbers
- ostream& operator <<(ostream& output, List& out)
- {
- output << out.size()<< endl;
- return output;
- }