• 接口声明的三种形式
  • 抛出一切形式的异常
void freeobj(mycoach &t)
{
    if (t.age < 16)
    {
        cout <<"精神可嘉~但还是年龄太小" <<endl;
        throw t.age;
    }
    if (t.months <= 12)
    {
        cout << "精神可嘉~再练一段时间,加油" << endl;
        throw t.months;
    }
    //throw t;
}
  • 抛出指定形式的异常
void freeobj(mycoach &t) throw(int, char,char*)
{
    if (t.age < 16)
    {
        cout <<"精神可嘉~但还是年龄太小" <<endl;
        throw t.age;
    }
    if (t.months <= 12)
    {
        cout << "精神可嘉~再练一段时间,加油" << endl;
        throw t.months;
    }
    //throw t;
}
  • 不抛异常
void freeobj(mycoach &t) throw()
{
    if (t.age < 16)
    {
        cout <<"精神可嘉~但还是年龄太小" <<endl;
        throw t.age;
    }
    if (t.months <= 12)
    {
        cout << "精神可嘉~再练一段时间,加油" << endl;
        throw t.months;
    }
    //throw t;
}
12-20 16:48