我正在尝试使用数组实现一个栈,但是我收到了一个错误。
class Stack{
private:
int cap;
int elements[this->cap]; // <--- Errors here
int top;
public:
Stack(){
this->cap=5;
this->top=-1;
};
指定的行存在以下错误:
Multiple markers at this line
- invalid use of 'this' at top level
- array bound is not an integer constant before ']' token
我做错了什么?
this
不存在... - Joe