home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / TCPP30-3.ZIP / EXAMPLES.ZIP / LIST2.H < prev    next >
C/C++ Source or Header  |  1992-02-18  |  794b  |  26 lines

  1. // Borland C++ - (C) Copyright 1991 by Borland International
  2.  
  3. // list2.h:   A Integer List Class
  4. // from Hands-on C++
  5. const int Max_elem = 10;
  6.  
  7. class List
  8. {
  9. protected:     // The protected keyword gives subclasses
  10.                // direct access to inherited members
  11.    int *list;        // An array of integers
  12.    int nmax;         // The dimension of the array
  13.    int nelem;        // The number of elements
  14.  
  15. public:
  16.    List(int n = Max_elem) {list = new int[n]; nmax = n; nelem = 0;};
  17.    ~List() {delete list;};
  18.    int put_elem(int, int);
  19.    int get_elem(int&, int);
  20.    void setn(int n) {nelem = n;};
  21.    int getn() {return nelem;};
  22.    void incn() {if (nelem < nmax) ++nelem;};
  23.    int getmax() {return nmax;};
  24.    virtual void print();                   // line 22
  25. };
  26.