home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c021 / 7.img / EXAMPLES.ZIP / LIST.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-04  |  596 b   |  22 lines

  1. // list.h:   A Integer List Class
  2. // from Chapter 6 of Getting Started
  3. const int Max_elem = 10;
  4.  
  5. class List
  6. {
  7.    int *list;        // An array of integers
  8.    int nmax;         // The dimension of the array
  9.    int nelem;        // The number of elements
  10.  
  11. public:
  12.    List(int n = Max_elem) {list = new int[n]; nmax = n; nelem = 0;};
  13.    ~List() {delete list;};
  14.    int put_elem(int, int);
  15.    int get_elem(int&, int);
  16.    void setn(int n) {nelem = n;};
  17.    int getn() {return nelem;};
  18.    void incn() {if (nelem < nmax) ++nelem;};
  19.    int getmax() {return nmax;};
  20.    void print();
  21. };
  22.