柚子快报邀请码778899分享:队列的链表实现

http://yzkb.51969.com/

/*

* queue_3.cpp

*

* Created on: 2013年8月2日

* Author: 黄俊东

* 目标章泽天。。。加油。。。。。

*

*/

#include

#include "list_2.h"

using namespace std;

typedef int T;

class Queue {

List l;

public:

Queue& push(const T& d) {

l.push_back(d);

return *this;

}

T pop() {

T t = l.front();

l.erase(0);

return t;

}

const T& front() {

return l.front();

}

const T& back() {

return l.back();

}

int size() {

return l.size();

}

void clear() {

l.clear();

}

bool empty() {

return l.empty();

}

bool full() {

return false;

}

};

int main() {

Queue q;

try {

q.push(1).push(2).push(3).push(4).push(5);

cout << q.pop() << endl;

cout << q.pop() << endl;

q.push(6).push(7).push(8);

} catch (const char* e) {

cout << "异常:" << e << endl;

}

while (!q.empty()) {

cout << q.pop() << endl;

}

}

柚子快报邀请码778899分享:队列的链表实现

http://yzkb.51969.com/

文章链接

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。