ex9.cpp

来自「c compiler with added projects...」· C++ 代码 · 共 32 行

CPP
32
字号
// Borland C++ - (C) Copyright 1991 by Borland International

// ex9.cpp:   Using the print() virtual function
// from Hands-on C++
#include <iostream.h>
#include "stack2.h"

main()
{
   Stack s(5);
   List l, *lp;
   int i = 0;

   // Insert the numbers 1 through 5 into the stack
   while (s.push(i+1) == 0)
      ++i;

   // Put a couple of numbers into the list
   l.put_elem(1,0);
   l.put_elem(2,1);
   l.setn(2);

   cout << "Stack:\n";
   lp = &s;           // line 22
   lp->print();       // Invoke the Stack print() method; line 23

   cout << "\nList:\n";
   lp = &l;
   lp->print();       // Invoke the List print() method; line 27
   return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?