This main program should ask the user to put in some numbers and store them into a dynamic array. The array should then be outputted its contents in a straight line, no end line commands, with a comma in between. I can't figure out how to start the program.

If you guys can help me find a way to do this, I would be eternally thankful!

Here is ListType.h:

```
#ifndef LISTTYPE_H_INCLUDED
#define LISTTYPE_H_INCLUDED
#include <iostream>

class ListType {
public:
 ListType(size_t=10);
 virtual ~ListType();
 virtual bool insert(int)=0;
 virtual bool erase();
 virtual bool erase(int)=0;
 virtual bool find(int) const=0;
 size_t size() const;
 bool empty() const;
 bool full() const;
 void output(std::ostream& out) const;
 friend std::ostream& operator << (std::ostream&, const ListType&);
protected:
 int *items;
 size_t capacity;
 size_t count;
};

#endif // LISTTYPE_H_INCLUDED

```

here is UListType.h:

```
#ifndef ULISTTYPE_H_INCLUDED
#define ULISTTYPE_H_INCLUDED
#include <iostream>

class UListType: public ListType {
public:
 UListType(size_t=10);
 bool insert(int);
 bool erase(int);
 bool find(int) const;
};

#endif // ULISTTYPE_H_INCLUDED

```

here is OListType.h:

```
#ifndef OLISTTYPE_H_INCLUDED
#define OLISTTYPE_H_INCLUDED
#include <iostream>

class OListType: public ListType {
public:
 OListType(size_t=10);
 bool insert(int);
 bool erase(int);
 bool find(int) const;
};

#endif // OLISTTYPE_H_INCLUDED

```

here is ListType.cpp:

```
#include "ListType.h"

ListType::ListType (size_t a) {
 capacity = a;
 count = 0;
 items = new int [capacity];
}

ListType::~ListType() {
 delete [] items;
}

bool ListType::erase() {
 count = 0;
 return 0;
}

size_t ListType::size() const {
 return (count);
}

bool ListType::empty() const {
 return (count == 0);
}

bool ListType::full() const {
 return (count == capacity);
}

void ListType::output(std::ostream& out) const {
 for (int i = 0; i < count; i++) {
      if (i > 0) {
        out << ", ";
      }
      out << items[i];
 }
}

std::ostream& operator << (std::ostream& out, const ListType& my_list) {
 my_list.output(out);
   return out;
}

```

here is UListType.cpp

```
#include "ListType.h"
#include "UListType.h"

UListType::UListType (size_t c): ListType(c) {}

bool UListType::insert(int item) {
 if (full()) {
    int *newitems;
    capacity *=2;
    newitems = new int[capacity];
    for (size_t i =0; i < count; ++i){
        newitems[i] = items[i];
    }
    delete [] items;
    items = newitems;
 }
 items[count++] = item;
 return true;
}

bool UListType::erase(int item) {
 bool result = false;
 size_t i=0;
 while ( i < count && items [i] != item) {
     ++i;
}
 if (i < count) {
    items[i] = items[-- count];
    result = true;
 }
 return result;
}

bool UListType::find(int item) const {
 size_t i = 0;
 while (i < count && items [i] != item) {
     ++i;
 }
 return i;
}

```

here is OListType.cpp

```
#include "ListType.h"
#include "OListType.h"

OListType::OListType(size_t c): ListType(c) {}

bool OListType::insert(int item) {
 size_t i = count;
 if (full()) {
    int *newitems;
    capacity *=2;
    newitems = new int[capacity];
    while (i > 0 && items[i-1] > item){
        newitems[i] = items[i];
    }
    delete [] items;
    items = newitems;
 }
 items[count++] = item;
 return true;
}

bool OListType::erase(int item) {
 bool found=false;
 size_t i=0, j= count-1, mid;
 while (i <= j && !(found)){
    mid = (i + j)/2;
    if (item < items [mid])
        j = mid - 1;
    else if (item > items [mid])
        i = mid + 1;
    found = items [mid] == item;
}
if (found) {
    for (i = mid; i < count - 1; ++i) {
        items [i] = items [i +1];
    }
     --count;
 }
 return found;
}

bool OListType::find (int item) const {
bool found=false;
 size_t i=0, j= count-1, mid;
 while (i <= j && !(found)){
    mid = (i + j)/2;
    if (item < items [mid])
        j = mid - 1;
    else if (item > items [mid])
        i = mid + 1;
    found = items [mid] == item;
 }
 return found;
}

```