I'm guessing my insert function isn't working correctly. It seems to be just inserting junk into my list whenever I print it out. I'm not getting any errors/warnings. Output generates something like: 91927492
I'm guessing my insert function isn't working correctly.
No need to guess. It isn't working correctly. When is the only time work is done in the insert function? Why does it return a value if you never check the value returned?
1 2 3 4 5 6 7 8 9 10 11 12 13
int main() {
UListType<int> ulist;
for (int i = 0; i < 11; ++i) {
if (ulist.insert(i)) cout << i << " successfully inserted.\n";
else cout << i << " was not successfully inserted.\n";
}
cout << ulist << endl;
system("pause");
return 0;
}
Thank you for your input cire, after doing your test it seems the first item inserted into the list succeeded (the 0) then every other input afterwards failed. The confusing part is this is the insert function my professor wrote xD and its not working of course