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 / EX9.CPP < prev    next >
C/C++ Source or Header  |  1992-02-18  |  691b  |  32 lines

  1. // Borland C++ - (C) Copyright 1991 by Borland International
  2.  
  3. // ex9.cpp:   Using the print() virtual function
  4. // from Hands-on C++
  5. #include <iostream.h>
  6. #include "stack2.h"
  7.  
  8. main()
  9. {
  10.    Stack s(5);
  11.    List l, *lp;
  12.    int i = 0;
  13.  
  14.    // Insert the numbers 1 through 5 into the stack
  15.    while (s.push(i+1) == 0)
  16.       ++i;
  17.  
  18.    // Put a couple of numbers into the list
  19.    l.put_elem(1,0);
  20.    l.put_elem(2,1);
  21.    l.setn(2);
  22.  
  23.    cout << "Stack:\n";
  24.    lp = &s;           // line 22
  25.    lp->print();       // Invoke the Stack print() method; line 23
  26.  
  27.    cout << "\nList:\n";
  28.    lp = &l;
  29.    lp->print();       // Invoke the List print() method; line 27
  30.    return 0;
  31. }
  32.