我想實現一個使用數組的堆棧,但我收到一個錯誤。獲取錯誤「數組綁定不是一個整數常量之前']'令牌'
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 2013-05-08 20:13:42
...和C++沒有沃拉斯。 – 2013-05-08 20:14:18
另外,編譯時必須知道成員數組的大小。 – 2013-05-08 20:14:20