本文提供《QUEUE.cpp》的C++源码下载,该代码实现了队列的基本功能,包括入队、出队和判空等操作。通过使用该代码,您可以快速了解队列的实现原理,并在实际项目中进行应用。源码结构清晰,注释详细,适合初学者学习和使用。请注意:本文仅提供源码下载,未提供编译后的可执行文件。如有需要,请自行编译并调试。具体的代码内容如下所示:

#include <iostream>
using namespace std;

#define SIZE 10

class Queue {
private:
    int arr[SIZE];
    int front;
    int rear;

public:
    Queue() {
        front = -1;
        rear = -1;
    }

    void enqueue(int value) {
        if (rear == SIZE - 1) {
            cout << "Queue is full" << endl;
        } else {
            if (front == -1) {
                front = 0;
            }
            rear++;
            arr[rear] = value;
            cout << "Inserted " << value << " in the queue" << endl;
        }
    }

    void dequeue() {
        if (front == -1) {
            cout << "Queue is empty" << endl;
        } else {
            cout << "Deleted " << arr[front] << " from the queue" << endl;
            if (front == rear) {
                front = -1;
                rear = -1;
            } else {
                front++;
            }
        }
    }

    void display() {
        if (front == -1) {
            cout << "Queue is empty" << endl;
        } else {
            for (int i = front; i <= rear; i++) {
                cout << arr[i] << " ";
            }
            cout << endl;
        }
    }

    bool isEmpty() {
        if (front == -1)
            return true;
        else
            return false;
    }
};

int main() {
    Queue q;
    q.enqueue(1);
    q.enqueue(2);
    q.enqueue(3);
    q.display();
    q.dequeue();
    q.display();

    return 0;
}
</iostream>