views:

55

answers:

1

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()); 
    }


}
+2  A: 

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.

GMan
@GMan, Solved the error, but curious to know why it was not throwing any error in VC6
Subhen
@Subhen: Not a clue. :) Probably had the same semantics, but VC6 was pre-standard and I haven't put much effort into learning it.
GMan