-1
CPP and
.h` 스택 파일과 내가 함께 컴파일하려고 할 때, 나는 두 가지 기능 bool empty()
을에오류 : ''이 범위에서 선언되지 않았습니다 [C++]
error: 'top_index' was not declared in...
같은 같은 오류가 발생하고 int size()
.
내 .cpp
코드는 다음과 같습니다
#include "char_stack.h"
char_stack::char_stack(){
top_index = -1;
}
void char_stack::push(char item){
top_index = top_index + 1;
A[top_index] = item;
}
char char_stack::pop(){
top_index = top_index - 1;
return A[top_index + 1];
}
char char_stack::top(){
return A[top_index];
}
bool empty(){
return top_index == -1;
}
int size(){
return top_index + 1;
}
내 .h
파일의 코드는 다음과 같습니다
class char_stack
{
public:
char_stack();
void push(char item);
char pop();
char top();
bool empty();
int size();
private:
static const int capacity = 250000;
int A[capacity];
int top_index;
};
누군가가 내가 뭘 잘못했는지 제발 도와주세요? 도 넣어 나는 문제 :(