Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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()); 
    }
   
    
}
like image 295
Simsons Avatar asked Jan 28 '26 06:01

Simsons


1 Answers

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.

like image 63
GManNickG Avatar answered Jan 29 '26 20:01

GManNickG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!