c++ - 我正在使用 Prototype does not match in any class error in c++
问题描述
#include <iostream>
using namespace std;
#define MAX 100;
class IntStack{
private:
int *stackArray;
int stackSize;
int top;
public:
IntStack();
bool isEmpty();
bool isFull();
void push();
void pop();
void displayStack();
void displayTopElement();
int test();
};
IntStack::IntStack(){
stackSize=MAX;
stackArray[stackSize];
top = 0;
}
IntStack::isEmpty(){
if(top == 0)
return 1;
else
return 0;
}
int main(){
IntStack intStack;
return 0;
}
我正在为 'int IntStack::isEmpty()' 的原型在我的编译器中与类 'IntStack' 中的任何错误不匹配,它还说候选是:bool IntStack::isEmpty()
我正在使用 Dev-C++ 5.11
我刚开始编码,所以其他功能是空的。
解决方案
这应该做你应该在定义中指定返回类型
bool IntStack::isEmpty(){
// to optimize the code you can do
return top==0;
}
推荐阅读
- php - 使用事件日历插件在事件标题下的月视图上显示特色图像
- angular - Angular 无法编译 ngb 分页错误 NG8002
- sas - 确定重叠时间范围内的间隙
- javascript - 为什么使用命令时我的代码无法访问?
- php - Instagram Graph Api 内容发布在 Graph API Explorer 上完美运行,但在浏览器和其他 HTTP 请求(包括 Curl)上出现故障
- django - Django:即使我的服务器重新启动,也继续执行 Cron 作业
- linux - Source a bash file with functions in another directory errors with 'command not found'
- python - 在 odoo 11 中制作 cron 以生成工资单批次
- php - 获取数组参数多
- amazon-web-services - 从 terraform 创建 AWS Aurora 数据库架构