#ifndef QUEUE_H_INCLUDED
#defineQUEUE_H_INCLUDED
class Queue {
int *buf;
int size;
int f, r;
public:
Queue(int s) : size(s), f(0), r(0) {
buf = new int[size+1];
}
~Queue() {
delete [] buf;
}
void push(int n) {
buf[f] = n;
f = (f +1) % (size+1);
}
int pop() {
int n = buf[r];
r = (r+1) % (size+1);
return n;
}
bool chkFull() const {
return (f + 1) % (size+1) == r;
}
bool chkEmpty() const {
return f == r;
}
};
#endif // !QUEUE_H_INCLUDED
제가 c++ 공부가 부족해서
교수님이 실행파일 만들 때 참고하라고 주신 이 헤더파일이 어떤 의미인지 잘 모르겠습니다.
알려주세요..
|