Depending on the runtime, the bool func will eval true or false. I did the debugging and sure enough it happens. I am wondering if there is an issue with my if statement.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
bool List<Object>::isDecreasing() const
{
bool isd = false;
ListNode<Object>* front = head;
ListNode<Object>* nodeafter = head->getNext();
/*if list is empty true*/
if (head->nextIsNull())
isd = true;
//checks if sorted. returns true even if a new value is sorted.
if (front > nodeafter)
isd = true;
if (front < nodeafter)
isd = false;
return isd;
Created list
1 2 3 4 5
int one = 1, two = 2, three = 3, four = 4, five = 5;
List<int> l1;
List<int> l2;
l1.insert(one);
l1.insert(two);
//tail( insert back) method
template <class Object>
void List<Object>::insert_back(const Object& data) {
Object a;
//allows multiple values to be entered. keeps pointing to next node
if (tail->getNext() == nullptr)
{
ListNode<Object>* wnode = new ListNode<Object>(data, nullptr);
tail->setNext(wnode);
tail = wnode;
}
//allows data to be inserted when list is empty, otherwise nothing is inserted
if (head->getNext() == nullptr)
{
ListNode<Object>* anode = new ListNode<Object>(data, head->getNext());
head->setNext(anode);
a = data;
}
}