int main () { QLinkedList<int> myQLinkedList; int sum (0); for (int i=1;i<=10;i++) myQLinkedList.push_back(i); assert(!myQLinkedList.empty()); while (!myQLinkedList.empty()) { sum += myQLinkedList.front(); myQLinkedList.pop_front(); } assert(myQLinkedList.empty()&&(myQLinkedList.size() == 0)); cout << "total: " << sum << endl; return 0; }
int main () { QLinkedList<int> myQLinkedList; int sum (0); myQLinkedList.push_back (100); myQLinkedList.push_back (200); myQLinkedList.push_back (300); assert(myQLinkedList.back() == 300); int n = 3; while (!myQLinkedList.empty()) { assert(myQLinkedList.back() == n*100); sum+=myQLinkedList.back(); myQLinkedList.pop_back(); n--; } cout << "The elements of myQLinkedList summed " << sum << endl; return 0; }