Expected a list to output?
I am expecting a list of 9,8,7,6,5,4... etc... however for some reason when I compile the code below, the screen just flashes at me...
If anyone wouldnt mind to look through and help out I would greatly appreciate it, thank you to whoever takes the time to help.
FUNCTION DEFINTION
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
template <class T>
bool typename UListType<T>::insert(const T& n) {
bool result = false;
if (this->full()) {
size_t capacity2 = this->capacity * 2;
T* temp = new T[capacity * 2];
if (temp != NULL) {
this->capacity = capacity2;
for (size_t i = 0; i < this->count; ++i)
{
temp[i] = this->list[i];
}
delete[] this->list;
this->list = temp;
this->list[this->count++] = n;
result = true;
}
}
else
{
this->list[this->count++] = n;
result = true;
}
return result;
}
|
FUNCTION DECLARATION
|
virtual bool insert(const T&) = 0;
|
MAIN .CPP file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include "UListType.h"
#include "UListType.h"
#include "OListType.h"
#include "ListType.h"
#include <iostream>
using namespace std;
int main() {
UListType<int> ulist;
for (int i = 10; i > 0; --i) {
ulist.insert(i);
}
cout << ulist << endl;
system("pause");
return 0;
}
|
solved:
problem with my ouput operator overload.
Topic archived. No new replies allowed.