c++ - '<' 无法解决类模板中的函数重载和参数不匹配问题,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# - 无法加载文件或程序集“Select.Html.dep”
- python - py_compile 是否有助于加快 python 脚本的速度?
- java - 从 Hibernate Criteria 迁移到 JPA 非常令人困惑。如何将此代码更改为 JPA 并将 disjunction() 与下面的 JPA 代码一起使用
- c# - 将 powerbi 嵌入式报告导出为 pdf。是否需要 Azure AD?
- python - 如何将变量(字符串)从 python 传递给 bash 脚本,然后回显它?
- google-chrome-extension - 我试图在使用清单 v3 时进行 chrome 扩展并获取 localStorage 未定义错误
- node.js - Nodemailer SMTP 连接被拒绝错误(NodeJS 服务器)
- php - 当我的中间件在 laravel 上运行时出现“调用字符串上的成员函数 send()”错误
- python - 使用 numpy 将 numpy 中的一列拆分为两个 - 使用 numpy.append 或 insert
- r - 如何计算每个 csv 数据帧列表的平均值