⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 11-5.cpp

📁 为初学者提供的最佳的C++程序设计源程序库
💻 CPP
字号:
#include<iostream.h>
#include<process.h>
const MAX =200;
class queue 
{
protected:
    int qdata[MAX];
    int tail,head;
public:
   queue(void)
   {
     tail=head=0;
   }
   void pushta(int i)
   {
    tail++;
    qdata[tail]=i;
    cout<<"tail="<<tail<<endl;
  }
   int pophe(void)
   {
	   head++;
	   cout<<"head="<<head<<endl;
	   return qdata[head];
   }
};
class queue2:public queue
{
public:
   void pushta(int i)
   {
     if(tail<MAX)
     queue::pushta(i);
     else
     {
      cout<<"queue is full\n";
      return;
      }
    }
    int pophe(void)
    {
     if(head<tail)
        return queue::pophe();
      else
       {
         cout<<"queue underflow\n";
         exit(1);
       }
     }
};
void main(void)
{
  queue2 q;
  q.pushta(123);
  q.pushta(456);
  cout<<"1:"<<q.pophe()<<endl;
  cout<<"2:"<<q.pophe()<<endl;
  cout<<"3:"<<q.pophe()<<endl;
}

⌨️ 快捷键说明

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