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

  1. // list.cpp:      Implementation of the List Class
  2.  
  3. #include <iostream.h>
  4. #include "list2.h"
  5.  
  6. int List::put_elem(int elem, int pos)
  7. {
  8.    if (0 <= pos && pos < nmax)
  9.    {
  10.       list[pos] = elem;
  11.       return 0;
  12.    }
  13.    else
  14.       return -1;     // non-zero means error
  15. }
  16.  
  17. int List::get_elem(int& elem, int pos)
  18. {
  19.    if (0 <= pos && pos < nmax)
  20.    {
  21.       elem = list[pos];
  22.       return 0;
  23.    }
  24.    else
  25.       return -1;     // non-zero means error
  26. }
  27.  
  28. void List::print()
  29. {
  30.    for (int i = 0; i < nelem; ++i)
  31.       cout << list[i] << "\n";
  32. }
  33.