void GetRecord(_RecordsetPtr pRs){
  pRs->GetCollect("Field");
}main(){
  try{
    _ConnectionPtr pCn("ADODB.Connection");
    _RecordsetPtr pRs("ADODB.Recordset");
    pCn->Open(...);
    pRs->Open(...);
    GetRecord(pRs);
  }catch(_com_error &e){
    ...
  }
}
--------
GetRecord是一个自定义的函数,现在的问题是,在这个函数中是否也要用try...?如果出错想在main中获取_com_error,将要如何写?
--------
不知这样写是否能看明白我的意思?希望能得到大家的帮助!在些先谢过

解决方案 »

  1.   

    C++ 有,C++ primer 上面有,但是我也是初学者~
      

  2.   

    try
        {
            buf = new char[512];
            if( buf == 0 )
                throw "Memory allocation failure!";
        }
        catch( char * str )
        {
            cout << "Exception raised: " << str << '\n';
        }
      

  3.   

    try
    {
    }
    catch( CException )
    {
      throw  "xxx";
    }
      

  4.   

    照throw就是拉
    与java不同的是throw什么类型都可以