home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / examples.pak / LIST2.CPP < prev    next >
Text File  |  1997-07-23  |  641b  |  35 lines

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