throw *

有下面两个类:

class base

{};

class sub : public base

{};

下面的异常代码:

try

{

    base *bb = new sub();

    throw(bb);

}

catch (sub*)

{

    std::cout<<”this handler won’t execute”;

}

catch (base*)

{

    std::cout<<”exxcute this handler”<<std::endl;

}

因此,最好不要throw指针类型的异常。

posted @ 2013-01-12 13:04  avexer  阅读(109)  评论(0编辑  收藏  举报