c03p155.txt
来自「Data Abstraction & Problem Solving with 」· 文本 代码 · 共 45 行
TXT
45 行
// *********************************************************// Header file ListAexcept.h for the ADT list// Array-based implementation with exceptions// *********************************************************#include "ListException.h"#include "ListIndexOutOfRangeException.h"const int MAX_LIST = maximum-size-of-list;typedef desired-type-of-list-item ListItemType;class List{public: List(); // default constructor // destructor is supplied by compiler// list operations: bool isEmpty() const; // Exception: None. int getLength() const; // Exception: None. void insert(int index, ListItemType newItem) throw(ListIndexOutOfRangeException, ListException); // Exception: Throws ListIndexOutOfRangeException if // index < 1 or index > getLength()+1. // Exception: Throws ListException if newItem cannot be // placed in the list because the array is full. void remove(int index) throw(ListIndexOutOfRangeException); // Exception: Throws ListIndexOutOfRangeException if // index < 1 or index > getLength(). void retrieve(int index, ListItemType& dataItem) const throw(ListIndexOutOfRangeException); // Exception: ListIndexOutOfRangeException if // index < 1 or index > getLength().private: ListItemType items[MAX_LIST]; // array of list items int size; // number of items in list int translate(int index) const;}; // end List class// End of header file.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?