c++实例研究

从0开始

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  104 随笔 :: 0 文章 :: 20 评论 :: 0 Trackbacks

 

/*  
*    Doc Name: Multiple Catch / Function throw
*    Prob Id: -
*    Serial Id: A.1
*    Author: -
*     Env: VS2008 Win32 Console
*    Date: 10/10/27
*/

#include 
"stdafx.h"
#include 
<iostream>
using namespace std;

void foo() throw ()
{
    
throw 5;
}


int _tmain(int argc, _TCHAR* argv[])
{

    
try{
        foo();
    }

    
catch(float e){
        cout
<<"caught global 1"<<endl;
    }

    
catch(int e){
        cout
<<"caught errno:"<<e<<endl;
    }

    
catch()
    
{
        
//exception should not caught here      
        cout<<"caught global 2"<<endl;
    }


    
return 0;
}



posted on 2010-10-27 17:35 elprup 阅读(691) 评论(0)  编辑 收藏 引用 所属分类: c++实例

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理