
Script started on Tue Mar 27 03:55:58 2007
[tsaiwn@ccbsd3]queue> g++ testmyq8.cpp
[tsaiwn@ccbsd3]queue> ./a.out
880 770 53
[tsaiwn@ccbsd3]queue> 

[tsaiwn@ccbsd3]queue> cat -n myq8.h
    1 //myq8.h === queue inhertae deque -- by tsaiwn@csie.nctu
    2 //~ (Inhertance) NO XR (extending)
    3 // `NoӨO Queue, aGNs MyStack, O template class
    4 #ifndef __MYQ8_H_
    5 #define __MYQ8_H_
    6 #include <deque>
    7 using namespace std;
    8 template <class T>
    9 class MyStack: deque<T> {   // `Ns  MyStack, O Queue 
   10 public:
   11    void push(const T& y) {
   12       MyStack<T>::push_back(y);   //  
   13    }
   14    T top( ) {
   15      return MyStack<T>::front( );   // Y 
   16    }
   17    void pop( ) {
   18      MyStack<T>::pop_front( );   // ڥ[J, Y, ҥHO Queue
   19    }
   20    bool empty( ) { 
   21      return MyStack<T>::begin() == MyStack<T>::end(); }
   22 };
   23 #endif

[tsaiwn@ccbsd3]queue> cat -n testmyq8.cpp
    1 // testmyq8.cpp -- by tsaiwn@csie.nctu
    2 //  g++ testmyq8.cpp  ; ./a.out
    3 #include "myq8.h"
    4 //`NHUO 1999᪺ C++ sgk, ªkϥ <iostream.h>
    5 #include<iostream>
    6 using namespace std;
    7 int main( ) {
    8    MyStack <int> x;   // `No! O queue !! ڬGNs MyStack
    9    x.push(880);
   10    x.push(770);
   11    x.push(53);
   12    while(!x.empty( )){
   13       cout << x.top( )<< " ";  x.pop( );
   14    }
   15    cout << endl;
   16 }// main(

[tsaiwn@ccbsd3]queue> g++ testmyq8.cpp
[tsaiwn@ccbsd3]queue> ./a.out
880 770 53
[tsaiwn@ccbsd3]queue> exit

exit
Script done on Tue Mar 27 03:57:58 2007


D:\test> path C:\Dev-Cpp\bin;%path%

D:\test> g++ testmyq8.cpp

D:\test> a.exe
880 770 53

D:\test> 
