using namespace std;
class AAA
{
public:
void ShowYou() { cout<<"AAA exception!"<<endl; }
};
class BBB : public AAA
{
public:
void ShowYou() { cout<<"BBB exception!"<<endl; }
};
class CCC : public BBB
{
public:
void ShowYou() { cout<<"CCC exception!"<<endl; }
};
void ExceptionGenerator(int expn)
{
if(expn==1)
throw AAA();
else if(expn==2)
throw BBB();
else
throw CCC();
}
int main(void)
{
try
{
ExceptionGenerator(3);
ExceptionGenerator(2);
ExceptionGenerator(1);
}
catch(AAA& expn)
{
cout<<"catch(AAA& expn)"<<endl;
expn.ShowYou();
}
catch(BBB& expn)
{
cout<<"catch(BBB& expn)"<<endl;
expn.ShowYou();
}
catch(CCC& expn)
{
cout<<"catch(CCC& expn)"<<endl;
expn.ShowYou();
}
return 0;
}
여기서 굵게 표시한 부분, AAA, BBB, CCC는 분명, 클래스 이름이잖아. ‘ShowYou()’라는 이름의 함수는 있어도, ‘AAA()’, ‘BBB()’, ‘CCC()’라는 이름의 함수는 아무리 찾아 봐도 없는데, 이 문장이 의미하는 것이 무엇임?
default constructor