funny problem about funtion-try-block in vc7.1

  • Thread starter Thread starter booker
  • Start date Start date
B

booker

Following code can't pass compilation

class CLS
:public exception
{
public:
CLS():exception("111")
{
}
};

void Fun()
try
{
throw CLS();
}
catch(...)
{
}
//; //adding this semicolon can pass compilation.

void Fun1()
{
}

if the class CLS does not derive from std::exception,it can pass compilation
too.

i think that this is a bug.
 
please add 2 line at the top of the source codes;

#include <exception>
using namespace std;
 
i have further discovery

class CLS
{
public:
virtual ~CLS()
{
}
};

void Fun()
try
{
throw CLS();
}
catch(...)
{
}
//; //adding this can pass compilation

void Fun1()
{
}

try these.
 
Back
Top