#include <iostream>
using namespace std;
class Stack {
int stack[10];
int top;
public :
Stack() { top=-1; }
Stack& operator <<(int n) {
top++;
stack[top] = n;
return *this;
}
Stack operator >>(int &n) {
n = stack[top];
top--;
return *this;
}
bool operator !() {
if( top == -1 ) return true;
else return false;
}
};
int main() {
Stack stack;
stack << 3 << 5 << 10;
while(true) {
if(!stack) break;
int x;
stack >> x;
cout << x << ' ';
}
cout << endl;
}
'언어 > C++' 카테고리의 다른 글
공 게임 ! (0) | 2019.11.29 |
---|---|
항공예약 프로그램 ! (0) | 2019.11.29 |
7장 9번 - 통계 클래스 만들기 (0) | 2019.11.28 |
7장 7번~8번 원 면적 (전위,후위 연산자 개념) (0) | 2019.11.28 |
7장 5~6번 Matrix 연산하기 (0) | 2019.11.28 |