首页 > 解决方案 > '<' 无法解决类模板中的函数重载和参数不匹配问题,Visual Studio 编译器

问题描述

显示错误的图像文件 指出的错误在 }; 之前的末尾。我什至没有看到任何函数重载或任何不匹配的参数。这只是我试图实现的一个队列数据结构。但不幸的是,我得到了这些编译器错误。我正在共享整个代码,以便轻松提供帮助,因为我没有任何函数重载,甚至没有构造函数,也没有使用不匹配的参数。我想图像将有助于查看错误。

template<class T>
class Queue {
private:
    T* box;
    int front;
    int rear;
    int number_Of_Elements;
    int capacity;
public:
    Queue(int cap = 0) {
        capacity = cap;
        front = rear = 0;
        number_Of_Elements = 0;
    }
    bool Empty() {
        return size == 0;
    }
    int next(int i) {
        return ((i + 1) % capacity);
    }
    int previous(int i) {
        return ((i + (capacity - 1)) % capacity);
    }
    int get_Number_Of_Elements() {
        return number_Of_Elements;
    }
    void double_Box() {
        T* temp = new T[capacity * 2];
        for (int i = 0; i < size; i++) {
            temp[i] = box[i];
        }
        front = 0;
        rear = number_Of_Elements;
        delete[] box;
        box = temp;
    }
    const T& peek() {
        T a = box[front];
        front = next(front);
        return a;
    }
    void printQueue() {
        cout << "Front is at : " << front << endl;
        cout << "Rear is at : " << rear << endl;
        for (int i = 0; i < number_Of_Elements; i++) {
            cout << "box[" << i << "]" << " : " << box[i] << endl;
        }
        cout << "------------------------" << endl;
    }
    void Enqueue(const T& data);
    const T& Dequeue();
    ~Queue() {
        delete[] box;
    }
// error is exactly here -> };
}; 

标签: c++compiler-errorsqueue

解决方案



推荐阅读