Hello, the code below (which was very kindly modified by somebody on-line )erases the objects contained in a list tempList that meet the 'if' condition. It works fine , but i don't understand how?. It basically steps through the for..next loop. I think the 'else' statement is confusing me.
void KillMutants2(list < mutantType> &tempList)
std::list < mutantType> ::iterator i;
for (auto it=tempList.begin();it!=tempList.end();)
if (it->getAge()==3 && it->IsMutant())
cout << "\nBunny " << it->getName() << " has died of old age";
Use of the iterator is very similar in concept to normal integers.
erase() returns an iterator to the item in the list that follows the item that was deleted. If nothing needs to be deleted than the else statement on line 13 take affect and the iterator is incremented.
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...
Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...