template <type,container> class queue是vc自带的队列类(从字面上理解的),可是我看了半天msdn也没看懂怎么用,试着编了一个试验程序编译没通过。请各位看在大家都是程序员的份上,帮兄弟一把,有什么有关文章或者源代码可以发到[email protected],多谢!

解决方案 »

  1.   

    //VC++6.0 SP6
    #include <list>
    #include <iostream>
    #include <queue>
    #include <deque>using namespace std ;// Using queue with list
    typedef list<int > INTLIST;
    typedef queue<int>  INTQUEUE;// Using queue with deque
    typedef deque<char*> CHARDEQUE;
    typedef queue<char*> CHARQUEUE;int main(void)
    {
        size_t size_q;
        INTQUEUE q;
        CHARQUEUE p;    // Insert items in the queue(uses list)
        q.push(42);
        q.push(100);
        q.push(49);
        q.push(201);    // Output the size of queue
        size_q = q.size();
        cout << "size of q is:" << size_q << endl;    // Output items in queue using front()
        // and use pop() to get to next item until
        // queue is empty
        while (!q.empty())
        {
            cout << q.front() << endl;
            q.pop();
        }// Insert items in the queue(uses deque)
        p.push("cat");
        p.push("ape");
        p.push("dog");
        p.push("mouse");
        p.push("horse");    // Output the item inserted last using back()
        cout << p.back() << endl;    // Output the size of queue
        size_q = p.size();
        cout << "size of p is:" << size_q << endl;    // Output items in queue using front()
        // and use pop() to get to next item until
        // queue is empty
        while (!p.empty())
        {
            cout << p.front() << endl;
            p.pop();
        }
    }
      

  2.   

    谢谢楼上,这段例子我在msdn里也看到了。queue class 中的type我想用自己定义的类,但是container不知道应该用什么