Hi All,
Compiling the code below should result in the "looser throw specifier" error from the gcc compiler. It does give me that error if I un-comment the destructor in the derived class. But the default destructor created by the compiler should will be essentially the same. So I'm wondering why this compiles.
Compiling the code below should result in the "looser throw specifier" error from the gcc compiler. It does give me that error if I un-comment the destructor in the derived class. But the default destructor created by the compiler should will be essentially the same. So I'm wondering why this compiles.
Code:
#include <iostream>
class Base {
public: Base() { std::cout << "Constructing base" << std::endl; }; virtual ~Base() throw() { std::cout << "Destroying base" << std::endl; };
};
class Derived : public Base {
public:
Derived() { std::cout << "Constructing derived" << std::endl; };
//~Derived() { std::cout << "Destroying derived" << std::endl; };
};
int main()
{
Base *b = new Derived();
delete b;
}
Comment