for (T<ItemType>* tempPtr = headPtr; tempPtr; tempPtr = tempPtr->getNext())
{
if (tempPtr->getItem() == newInput)
throw DuplicateItemError();
}
So in the header after initialization, "tempPtr;" is this just saying run this loop while this pointer is true?
In other words, this for loop will run regardless because tempPtr will always be true since we initialized it in the first part of the for loop?
I have seen other short methods of writing loops or returns and it just amazes me and I get confused that it can be so short.
is this just saying run this loop while this pointer is true?
Yes, that's essentially what it's saying. When you use a pointer where a boolean expression is expected null will be treated as false and all other pointers (i.e. pointers that point to something) will be treated as true.
Oh that's awesome, and powerful! It really is count controlled secretly the whole time. Because we can start at whatever headPtr is and then keep going until it sees a nullptr. wow. I am used to seeing things more obviously set as an integer to work with.