옵션 |
|
template <typename T>
void Stack<T>::push(const T& pushValue) {
if (this->topIndex >= STACK_MAX - 1) {
StackFullException e(this, this->topIndex);
throw &e;
}
this->stackPtr[++this->topIndex] =
pushValue;
// -1 -> 0이 되고 나서 대입
}
Stack<int> stack5(STACK_MAX);
for (int i = 0; i < 5; i++) {
try {
cout << "i : " << i << endl;
stack5.push(10 * i);
}
catch (const char* msg) {
cout << "예외 종류 : " << msg << endl;
}
catch (MyException *ePtr) {
ePtr->report();
}
}
핵심코드만 빼서 박았습니다.