1: // Created by Frank M. Carrano and Timothy M. Henry. 2: // Copyright (c) 2017 Pearson Education, Hoboken, New Jersey. 4: template<class ItemType> 5: ItemType LinkedList<ItemType>::getEntry(int position) const 6: throw(PrecondViolatedExcept) 7: { 8: // Enforce precondition 9: bool ableToGet = (position >= 1) && (position <= itemCount); 10: if (ableToGet) 11: { 12: Node<ItemType>* nodePtr = getNodeAt(position); 13: return nodePtr –>getItem(); 14: } 15: else 16: { 17: std::string message = "getEntry() called with an empty list or "; 18: message = message + "invalid position."; 19: throw(PrecondViolatedExcept(message)); 20: } // end if 21: } // end getEntry