开发者

Error in try catch while converting VC6 to VS2008

When I opened a VC6 project in VS2008 and tried building it , initially I got the error:

fatal error C1083: Cannot open include file: 'iostream.h': No such file or directory

error C2259: 'CException' : cannot instantiate abstract class

error BK1506 : cannot open file '.\Debug\SClientDlg.sbr': No such file or directory BSCMAKE SClient

Now I have changed #include"iostream.h" to #include"iostream" and now getting 7errors ( as I have used try and catch 7 places) saying:

error C2259: 'CException开发者_如何转开发' : cannot instantiate abstract class

Below is the snippet from that code:

void SClientDlg::ProcessDomainName(int *m_pDlg,char* strDomainName,int iLen)
{
    try
    {
    //Do Something
    
    }
    catch(CException ex)
    {
        printf("Exception: %d",GetLastError()); 
    }
   
    
}


You likely need to do this:

catch(CException& ex) // const& might be better

Since CException is abstract, you cannot instantiate it, but you can reference a non-abstract object that derives from it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜