#include <iostream>
using namespace std;

#define SIZE 100

class stack {
	char memory[SIZE];
	int top;
	char who;
public:
   	stack(char c);
	void push(char ch);
	char pop();
};

stack::stack(char c){
	top = 0;
	who = c;
	
	cout << "スタック'" << who << "'を生成する。\n";
}

void stack::push(char ch){
	if (top >= SIZE) {
		cout << "スタック'" << who << "'は一杯です。\n";
		return;
	}
	memory[top++] = ch;
}

char stack::pop(){
	if (top <= 0){
		cout << "スタック'" << who << "'は空です。\n";
		return 0;
	}
	return memory[--top];
}

int main(){
	stack s1('A'),s2('B');
	s1.push('a');
	s2.push('x');
	s1.push('b');
	s2.push('y');
	s1.push('c');
	s2.push('z');
	
	for (int i = 0; i < 5; i++){
		cout << "s1をポップする: " << s1.pop() << "\n";
	}
	for (int i = 0; i < 5; i++){
		cout << "s2をポップする: " << s2.pop() << "\n";
	}
	return 0;
} 